談到國際化& Unicode,我是一個白癡的美國程序員。這筆交易。字符串文字basic_string <unsigned char>
#include <string>
using namespace std;
typedef basic_string<unsigned char> ustring;
int main()
{
static const ustring my_str = "Hello, UTF-8!"; // <== error here
return 0;
}
這發出一個不意外的投訴:
cannot convert from 'const char [14]' to 'std::basic_string<_Elem>'
也許今天我有咖啡的錯誤部分。我該如何解決?我可以保持基本結構:
ustring something = {insert magic incantation here};
?
不回答你的問題,但閱讀這篇文章在i18n:http://www.joelonsoftware.com/articles/Unicode.html – Starkey 2010-09-30 20:36:41
看過它,但thx – 2010-09-30 20:39:34
你可能需要提供你自己的'char_traits'專業化。 AFAIK,''只提供'char'和'wchar_t'的專門化。 –
Praetorian
2010-09-30 20:44:08