locale_information.html 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.6"/>
  7. <title>Boost.Locale: Getting information about the current locale</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type="text/javascript" src="dynsections.js"></script>
  11. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  12. <script type="text/javascript" src="resize.js"></script>
  13. <script type="text/javascript" src="navtree.js"></script>
  14. <script type="text/javascript">
  15. $(document).ready(initResizable);
  16. $(window).load(resizeHeight);
  17. </script>
  18. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  19. </head>
  20. <body>
  21. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  22. <div id="titlearea">
  23. <table cellspacing="0" cellpadding="0">
  24. <tbody>
  25. <tr style="height: 56px;">
  26. <td id="projectlogo"><img alt="Logo" src="boost-small.png"/></td>
  27. <td style="padding-left: 0.5em;">
  28. <div id="projectname">Boost.Locale
  29. </div>
  30. </td>
  31. </tr>
  32. </tbody>
  33. </table>
  34. </div>
  35. <!-- end header part -->
  36. <!-- Generated by Doxygen 1.8.6 -->
  37. <div id="navrow1" class="tabs">
  38. <ul class="tablist">
  39. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  40. <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
  41. <li><a href="modules.html"><span>Modules</span></a></li>
  42. <li><a href="namespaces.html"><span>Namespaces</span></a></li>
  43. <li><a href="annotated.html"><span>Classes</span></a></li>
  44. <li><a href="files.html"><span>Files</span></a></li>
  45. <li><a href="examples.html"><span>Examples</span></a></li>
  46. </ul>
  47. </div>
  48. </div><!-- top -->
  49. <div id="side-nav" class="ui-resizable side-nav-resizable">
  50. <div id="nav-tree">
  51. <div id="nav-tree-contents">
  52. <div id="nav-sync" class="sync"></div>
  53. </div>
  54. </div>
  55. <div id="splitbar" style="-moz-user-select:none;"
  56. class="ui-resizable-handle">
  57. </div>
  58. </div>
  59. <script type="text/javascript">
  60. $(document).ready(function(){initNavTree('locale_information.html','');});
  61. </script>
  62. <div id="doc-content">
  63. <div class="header">
  64. <div class="headertitle">
  65. <div class="title">Getting information about the current locale </div> </div>
  66. </div><!--header-->
  67. <div class="contents">
  68. <div class="textblock"><p>The <code>std::locale::name</code> function provides very limited information about a locale. Such a name is platform- and compiler-dependent, and is useless for Boost.Locale. There is no way to change it, so for all locales created by Boost.Locale, <code>name()</code> returns the same value as <code>name()</code> for <code>std::locale::classic()</code>.</p>
  69. <p>Thus an additional facet was created, giving more precise information: <a class="el" href="classboost_1_1locale_1_1info.html" title="a facet that holds general information about locale ">boost::locale::info</a>. It has the following member functions:</p>
  70. <ul>
  71. <li><a class="el" href="classboost_1_1locale_1_1info.html#af8181bf226f369548c030220932323b9">std::string name()</a> &ndash; the full name of the locale, for example <code>en_US.UTF-8</code> </li>
  72. <li><a class="el" href="classboost_1_1locale_1_1info.html#a7c56b9df3aba82649afc66c06192c7df">std::string language()</a> &ndash; the ISO-639 language code of the current locale, for example "en".</li>
  73. <li><a class="el" href="classboost_1_1locale_1_1info.html#a249c20e36da6827a8dc8b12a8342a7dc">std::string country()</a> &ndash; the ISO-3199 country code of the current locale, for example "US".</li>
  74. <li><a class="el" href="classboost_1_1locale_1_1info.html#a2e949e4362c8f0195e2a645fe875f1b4">std::string variant()</a> &ndash; the variant of current locale, for example "euro".</li>
  75. <li><a class="el" href="classboost_1_1locale_1_1info.html#a1979a5d7b90604c45e856a139c68f5ba">std::string encoding()</a> &ndash; the encoding used for <code>char</code> based strings, for example "UTF-8"</li>
  76. <li><a class="el" href="classboost_1_1locale_1_1info.html#aafbbb5c291f60ce6fc3bc056859ba181">bool utf8()</a> &ndash; a fast way to check whether the encoding is UTF-8.</li>
  77. </ul>
  78. <p>For example:</p>
  79. <div class="fragment"><div class="line">cout &lt;&lt; <span class="stringliteral">&quot;The language code is &quot;</span> &lt;&lt; std::use_facet&lt;boost::locale::info&gt;(some_locale).language() &lt;&lt; endl;</div>
  80. </div><!-- fragment --> </div></div><!-- contents -->
  81. </div><!-- doc-content -->
  82. <li class="footer">
  83. &copy; Copyright 2009-2012 Artyom Beilis, Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License</a>, Version 1.0.
  84. </li>
  85. </ul>
  86. </div>
  87. </body>
  88. </html>