Sorry, I just realized that because you are embedding Julia, you probably have a wchar_t
string in C++ that you want to convert to a Unicode String
in Julia at runtime.
Since your std::wstring
is a wchar_t*
string (UTF-16 on Windows and UTF-32 everywhere else), it a different encoding than the UTF-8 encoding used by the Julia String
type, so you need to either convert it (the transcode
function in Base can do this) or use the WString
type in the LegacyStrings
package (to use it in Julia without conversion, e.g. to share memory for large strings).
e.g. suppose you pass the data as a wchar_t *p
(or p::Ptr{Cwchar_t}
in Julia) and a length L
. Then you could call transcode(String, unsafe_wrap(p, L))
to get a Julia String
object.