I'm struggling to get started with the C++ ICU library. I have tried to get the simplest example to work, but even that has failed. I would just like to output a UTF-8 string and then go from there.
Here is what I have:
#include <unicode/unistr.h>
#include <unicode/ustream.h>
#include <iostream>
int main()
{
UnicodeString s = UNICODE_STRING_SIMPLE("привет");
std::cout << s << std::endl;
return 0;
}
Here is the output:
$ g++ -I/sw/include -licucore -Wall -Werror -o icu_test main.cpp
$ ./icu_test
пÑивеÑ
My terminal and font support UTF-8 and I regularly use the terminal with UTF-8. My source code is in UTF-8.
I think that perhaps I somehow need to set the output stream to UTF-8 because ICU stores strings as UTF-16, but I'm really not sure and I would have thought that the operators provided by ustream.h would do that anyway.
Any help would be appreciated, thank you.