Randy W. Sims <[EMAIL PROTECTED]> writes:
>On 03/08/04 12:26, Tels wrote:
>> 
>> Good news: I asked on the Irrlicht board, and their very helpfull answer 
>> was, use some obsucre conversation function:
>> 
>> void
>> setWindowCaption(SV* classname, char* caption)
>>   PREINIT:
>>     wchar_t mytitle[512];
>>   CODE:
>>     // TODO: find out length of scalar and alloc memory for myTitle?
>>     mbstowcs(mytitle, caption, 512);

I think the normal way to get the length is to use the related 
function mbsrtowcs() twice - once passing NULL as dest to get 
character count, the malloc-ing buffer and then calling again
to do the actual conversion.



>>     device->setWindowCaption(mytitle);
>> 
>> This works! :) However, whoever thought up the name of these conversion 
>> functions should be shot. Honestly, who can remember these cryptic garbage 
>> names like mbscwsomethingfoobar? Glad that I have to write it only once as 
>> macro in XS :)
>> 
>
>Multi-Byte String TO Wide Character String. I don't think that function 
>is portable though, but I could be wrong. 
>And it doesn't seem like the 
>right conversion function to convert ascii to wide char, but I could be 
>wrong about that too - I know almost nothing about wide strings :(.

It doesn't convert from ASCII as such, but rather the locale specfic 
multibyte encoding that is assumed to be the "on disk" representation.
It can be the right thing to use to convert from UTF-8 if one is in a
UTF8-locale. Most european non-UTF-8 locales are not really "multibyte",
but none the less the above works.

Note that perl strings are usually either in UTF-8 - in which case 
above is only correct if you are in a UTF-8 locale - or as "octets" 
which are perhaps treated as characters in either iso-8859-1 or 
- if you have explicitly asked for it - a locale specific encoding.
(This may not matter in practice - perl's intent is to "just work".)

 




>
>Randy.

Reply via email to