I'm having problems converting a wstring to jstring in unix, as the size of wchar_t on linux in 4 bytes (not 2 bytes like windows and thus I cannot use the casting of a wchar_t to a jchar).
Can anyone please help me with that?
Thanks, Reza
I'm having problems converting a wstring to jstring in unix, as the size of wchar_t on linux in 4 bytes (not 2 bytes like windows and thus I cannot use the casting of a wchar_t to a jchar).
Can anyone please help me with that?
Thanks, Reza
You have to use something like
iconv()
, because C++ wide strings have an opaque (read: unknown) encoding, while Java expects UTF16. Try this:If you don't have
char16_t
andstd::u16string
, you can useuint16_t
as the basic character type andstd::basic_string<uint16_t>
orstd::vector<uint16_t>
as the resulting container.