Cообщество разработчиков на платформе Microsoft > Форумы > Visual C++ General > std::locale::global(std::locale("zh-CN")) Gets "Bad locale name"??
Задайте вопросЗадайте вопрос
 

Отвеченоstd::locale::global(std::locale("zh-CN")) Gets "Bad locale name"??

  • 14 апреля 2009 г. 3:30FredHe Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Hi everyone:

           I'm playing with C/C++ locale recently.
           I've got a program which uses Chinese character as file name or in the path of a file. When using fstream to manipulate files, I choose to use MBCS instead of Unicode, so I have to specify the locale.
          At first I tried setlocale(LC_CTYPE, "chinese") and it works well, however, it's a C-style locale setting, for C++, std::locale::global() is preferable. Unfortunately, I just can't set the correct locale by calling std::locale::global(). I have tried: std::locale::global(std::locale("zh-CN")); but I get a "Bad locale name" exception, it's strange, because "zh-CN" conforms to the specification defined in MSDN(http://msdn.microsoft.com/en-us/library/dd373814(VS.85).aspx). Later I found  std::locale::global(std::locale("Chinese")); works well, then I'm totally confused. Could anybody figure it out?

Ответы

Все ответы