When it comes to internationalization & Unicode, I\'m an idiot American programmer. Here\'s the deal.
#include
using namespace std;
typedef
Using different character types for a different encodings has the advantages that the compiler barks at you when you mess them up. The downside is, you have to manually convert.
A few helper functions to the rescue:
inline ustring convert(const std::string& sys_enc) {
return ustring( sys_enc.begin(), sys_enc.end() );
}
template< std::size_t N >
inline ustring convert(const char (&array)[N]) {
return ustring( array, array+N );
}
inline ustring convert(const char* pstr) {
return ustring( reinterpret_cast(pstr) );
}
Of course, all these fail silently and fatally when the string to convert contains anything other than ASCII.