I am trying to convert a Hebrew characters into UTF-8
and store them in a std::string
.
I thought I’d give ICU a try.
Here is my minimal example:
#include <string>
#include <unicode/ustream.h>
int main(int argc, char** argv)
{
icu::UnicodeString us = L"עידן";
std::string s;
us.toUTF8String(s);
return EXIT_SUCCESS;
}
I would expect s
to contain the same characters as the UnicodeString
(although in UTF-8).
However, when looking at s
in the debugger, the value of the string is: עידן
.
I am clearly misunderstanding something about how to properly convert these unicode characters to fit and be understood using char
.
What am I doing wrong here?