On Wednesday, May 14, 2014 9:06:52 AM UTC-4, Samuel Colvin wrote: > > The *4* is requied because the original string was Cwchar_t so 4 times > the size. I'm not sure of the legitimacy of changing the pointer type from > Ptr{Cwchar_t} to Ptr{Uint8} ??? but it seems to work >
Probably a bad idea. You need to figure out what character encoding your wchar_t* data is using. If typecasting to Ptr{Uint8} and calling bytestring works, then it may not be wchar_t data at all.... it may be either ASCII or UTF-8 (or something worse, like Latin1), i.e. a one-byte encoding. On Windows, my understanding is that sizeof(wchar_t) is usually 2, and wchar strings point to little-endian UTF-16 data. In this case, if you have a key::Ptr{Uint16}, you can do: utf16(pointer_to_array(key, key_length, false)) to get a UTF16String object in Julia (that can easily be converted to other string types). Change "false" to "true" if you want Julia to be in charge of calling free() on the data pointer. On GNU/Linux and OS X, my understanding is that sizeof(wchar_t) is usually 4 and represents little-endian UTF-32 data. In this case, if you have a key::Ptr{Char}, you can do: UTF32String(pointer_to_array(key, key_length, false)) to get a UTF16String object.