When it comes to internationalization & Unicode, I\'m an idiot American programmer. Here\'s the deal.
#include
using namespace std;
typedef
Narrow string literals are defined to be const char
and there aren't unsigned string literals[1], so you'll have to cast:
ustring s = reinterpret_cast("Hello, UTF-8");
Of course you can put that long thing into an inline function:
inline const unsigned char *uc_str(const char *s){
return reinterpret_cast(s);
}
ustring s = uc_str("Hello, UTF-8");
Or you can just use basic_string
and get away with it 99.9% of the time you're dealing with UTF-8.
[1] Unless char
is unsigned, but whether it is or not is implementation-defined, blah, blah.