码迷,mamicode.com
首页 > 其他好文 > 详细

wcout输出中文不显示

时间:2014-11-23 17:23:31      阅读:664      评论:0      收藏:0      [点我收藏+]

标签:des   io   ar   使用   sp   strong   on   log   bs   

准备使用UNICODE来写个控制台测试程序发现,cout无法输出UNICODE的中文字符。查找c++标准看到,其提供了wcin、wcout、wcerr、wclog用于处理wchar_t字符的输入输出。

在vs10中调用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"

Czech

Czech

"csy" or "czech"

Danish

Danish

"dan" or "danish"

Dutch

Dutch (default)

"dutch" or "nld"

Dutch

Dutch (Belgium)

"belgian", "dutch-belgian", or "nlb"

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", "american english", "american-english", "english-american", "english-us", "english-usa", "enu", "us", or "usa"

Finnish

Finnish

"fin" or "finnish"

French

French (default)

"fra" or "french"

French

French (Belgium)

"frb" or "french-belgian"

French

French (Canada)

"frc" or "french-canadian"

French

French (Switzerland)

"french-swiss" or "frs"

German

German (default)

"deu" or "german"

German

German (Austria)

"dea" or "german-austrian"

German

German (Switzerland)

"des", "german-swiss", or "swiss"

Greek

Greek

"ell" or "greek"

Hungarian

Hungarian

"hun" or "hungarian"

Icelandic

Icelandic

"icelandic" or "isl"

Italian

Italian (default)

"ita" or "italian"

Italian

Italian (Switzerland)

"italian-swiss" or "its"

Japanese

Japanese

"japanese" or "jpn"

Korean

Korean

"kor" or "korean"

Norwegian

Norwegian (default)

"norwegian"

Norwegian

Norwegian (Bokmal)

"nor" or "norwegian-bokmal"

Norwegian

Norwegian (Nynorsk)

"non" or "norwegian-nynorsk"

Polish

Polish

"plk" or "polish"

Portuguese

Portuguese (default)

"portuguese" or "ptg"

Portuguese

Portuguese (Brazil)

"portuguese-brazilian" or "ptb"

Russian

Russian (default)

"rus" or "russian"

Slovak

Slovak

"sky" or "slovak"

Spanish

Spanish (default)

"esp" or "spanish"

Spanish

Spanish (Mexico)

"esm" or "spanish-mexican"

Spanish

Spanish (Modern)

"esn" or "spanish-modern"

Swedish

Swedish

"sve" or "swedish"

Turkish

Turkish

"trk" or "turkish"

 

wcout输出中文不显示

标签:des   io   ar   使用   sp   strong   on   log   bs   

原文地址:http://www.cnblogs.com/tocy/p/wcout-show-chinese-failed.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!