• <bdo id='yHGM7'></bdo><ul id='yHGM7'></ul>
  • <legend id='yHGM7'><style id='yHGM7'><dir id='yHGM7'><q id='yHGM7'></q></dir></style></legend>
  • <i id='yHGM7'><tr id='yHGM7'><dt id='yHGM7'><q id='yHGM7'><span id='yHGM7'><b id='yHGM7'><form id='yHGM7'><ins id='yHGM7'></ins><ul id='yHGM7'></ul><sub id='yHGM7'></sub></form><legend id='yHGM7'></legend><bdo id='yHGM7'><pre id='yHGM7'><center id='yHGM7'></center></pre></bdo></b><th id='yHGM7'></th></span></q></dt></tr></i><div id='yHGM7'><tfoot id='yHGM7'></tfoot><dl id='yHGM7'><fieldset id='yHGM7'></fieldset></dl></div>
    <tfoot id='yHGM7'></tfoot>
  • <small id='yHGM7'></small><noframes id='yHGM7'>

        打印所有 std::locale 名称 (Windows)

        时间:2023-07-19
          <tfoot id='u1scT'></tfoot>
            <tbody id='u1scT'></tbody>
              <bdo id='u1scT'></bdo><ul id='u1scT'></ul>
            • <legend id='u1scT'><style id='u1scT'><dir id='u1scT'><q id='u1scT'></q></dir></style></legend>

                  <i id='u1scT'><tr id='u1scT'><dt id='u1scT'><q id='u1scT'><span id='u1scT'><b id='u1scT'><form id='u1scT'><ins id='u1scT'></ins><ul id='u1scT'></ul><sub id='u1scT'></sub></form><legend id='u1scT'></legend><bdo id='u1scT'><pre id='u1scT'><center id='u1scT'></center></pre></bdo></b><th id='u1scT'></th></span></q></dt></tr></i><div id='u1scT'><tfoot id='u1scT'></tfoot><dl id='u1scT'><fieldset id='u1scT'></fieldset></dl></div>

                  <small id='u1scT'></small><noframes id='u1scT'>

                  本文介绍了打印所有 std::locale 名称 (Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的程序检查德语中的大写字母.

                  My program checks for uppercase letters in German language.

                  #include <iostream>
                  #include <boost/algorithm/string/classification.hpp>
                  #include <boost/locale.hpp>
                  
                  using namespace std;
                  
                  int main()
                  {
                      locale::global(locale("Germany_german"));
                      //locale::global(locale("de_DE.UTF-8")); //Also tried "de_DE.UTF-8", but does not work
                  
                      string str1 = "über";
                      cout << boolalpha << any_of(str1.begin(), str1.end(), boost::algorithm::is_upper()) << endl;
                  
                      string str2 = "";
                      cout << boolalpha << any_of(str2.begin(), str2.end(), boost::algorithm::is_upper()) << endl;
                  
                      return 0;
                  }
                  

                  程序在控制台上因错误而崩溃

                  program crashes with error on console

                  terminate called after throwing an instance of 'std::runtime_error'
                    what():  locale::facet::_S_create_c_locale name not valid
                  

                  我不知道确切的语言环境字符串是什么,de_DE.UTF-8"也不起作用.

                  I don't know what that exact locale string is, "de_DE.UTF-8" doesn't work as well.

                  有什么方法可以获得操作系统支持的所有语言环境的准确语言环境名称字符串.可能在头文件的某处有一个列表,但我没有看到任何 <locale> 头.

                  Is there any way I can get exact locale name strings for all locales supported by OS. May be there is a list somewhere in header files, but I don't see anything <locale> header.

                  推荐答案

                  我编写了一个程序来打印所有支持的语言环境名称.

                  I wrote a program to print all supported locale names.

                  #include <Windows.h>
                  
                  #include <iostream>
                  #include <string>
                  #include <vector>
                  #include <algorithm>
                  #include <ostream>
                  #include <iterator>
                  
                  using namespace std;
                  
                  vector<wstring> locals;
                  
                  BOOL CALLBACK MyFuncLocaleEx(LPWSTR pStr, DWORD dwFlags, LPARAM lparam)
                  {
                      locals.push_back(pStr);
                      return TRUE;
                  }
                  
                  int _tmain(int argc, _TCHAR* argv[])
                  {
                      EnumSystemLocalesEx(MyFuncLocaleEx, LOCALE_ALL, NULL, NULL);
                  
                      for (vector<wstring>::const_iterator str = locals.begin(); str != locals.end(); ++str)
                          wcout << *str << endl;
                  
                      wcout << "Total " << locals.size() << " locals found." << endl;
                  
                      return 0;
                  }
                  

                  效果很好.

                  ...
                  de
                  de-AT
                  de-CH
                  de-DE
                  de-DE_phoneb
                  de-LI
                  de-LU
                  ...    
                  Total 429 locals found.
                  

                  这篇关于打印所有 std::locale 名称 (Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:boost::filesystem::recursive_directory_iterator 带过滤器 下一篇:如何实现“可变模板"使用 pre-c++0x(VS2008)?

                  相关文章

                  <i id='ldxlP'><tr id='ldxlP'><dt id='ldxlP'><q id='ldxlP'><span id='ldxlP'><b id='ldxlP'><form id='ldxlP'><ins id='ldxlP'></ins><ul id='ldxlP'></ul><sub id='ldxlP'></sub></form><legend id='ldxlP'></legend><bdo id='ldxlP'><pre id='ldxlP'><center id='ldxlP'></center></pre></bdo></b><th id='ldxlP'></th></span></q></dt></tr></i><div id='ldxlP'><tfoot id='ldxlP'></tfoot><dl id='ldxlP'><fieldset id='ldxlP'></fieldset></dl></div>
                1. <tfoot id='ldxlP'></tfoot>
                  • <bdo id='ldxlP'></bdo><ul id='ldxlP'></ul>
                2. <legend id='ldxlP'><style id='ldxlP'><dir id='ldxlP'><q id='ldxlP'></q></dir></style></legend>

                  <small id='ldxlP'></small><noframes id='ldxlP'>