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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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_tandstd::u16string, you can useuint16_tas the basic character type andstd::basic_string<uint16_t>orstd::vector<uint16_t>as the resulting container.