准备使用UNICODE来写个控制台测试程序发现,cout无法输出UNICODE的中文字符。查找C++标准看到,其提供了wcin、wcout、wcerr、wclog用于处理wchar_t字符的输入输出。
在VS2008中调用wcout不显示中文字符,可以使用下面方式处理:
wcout输出时显示不了中文,加上下面这句就行了。
std::wcout.imbue(std::locale("chs"));
Primary language Sublanguage Language string
Chinese Chinese "chinese"
Chinese Chinese (simplified) "chinese-simplified" or "chs"
Chinese Chinese (traditional) "chinese-traditional" or "cht"
English English (default) "english"
English English (Australia) "australian","ena",or english-aus"
English English (Canada) "canadian","enc",or "english-can"
English English (New Zealand) "english-nz" or "enz"
English English (United Kingdom) "eng", "english-uk", or "uk"
English English (United States) "american", "us", or "usa" etc.