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">
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: whello.cpp
</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);
18 <link href=
"doxygen.css" rel=
"stylesheet" type=
"text/css" />
21 <div id=
"top"><!-- do not remove this div, it is closed by doxygen! -->
23 <table cellspacing=
"0" cellpadding=
"0">
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
35 <!-- end header part -->
36 <!-- Generated by Doxygen 1.8.6 -->
37 <div id=
"navrow1" class=
"tabs">
39 <li><a href=
"index.html"><span>Main
 Page
</span></a></li>
40 <li><a href=
"pages.html"><span>Related
 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>
49 <div id=
"side-nav" class=
"ui-resizable side-nav-resizable">
51 <div id=
"nav-tree-contents">
52 <div id=
"nav-sync" class=
"sync"></div>
55 <div id=
"splitbar" style=
"-moz-user-select:none;"
56 class=
"ui-resizable-handle">
59 <script type=
"text/javascript">
60 $(document).ready(function(){initNavTree('whello_8cpp-example.html','');});
62 <div id=
"doc-content">
64 <div class=
"headertitle">
65 <div class=
"title">whello.cpp
</div> </div>
67 <div class=
"contents">
68 <p>Basic example of using various functions with wide strings provided by this library
</p>
69 <div class=
"fragment"><div class=
"line"><span class=
"comment">//
</span></div>
70 <div class=
"line"><span class=
"comment">// Copyright (c)
2009-
2011 Artyom Beilis (Tonkikh)
</span></div>
71 <div class=
"line"><span class=
"comment">//
</span></div>
72 <div class=
"line"><span class=
"comment">// Distributed under the Boost Software License, Version
1.0. (See
</span></div>
73 <div class=
"line"><span class=
"comment">// accompanying file LICENSE_1_0.txt or copy at
</span></div>
74 <div class=
"line"><span class=
"comment">// http://www.boost.org/LICENSE_1_0.txt)
</span></div>
75 <div class=
"line"><span class=
"comment">//
</span></div>
76 <div class=
"line"><span class=
"preprocessor">#include
<boost/locale.hpp
></span></div>
77 <div class=
"line"><span class=
"preprocessor">#include
<iostream
></span></div>
78 <div class=
"line"></div>
79 <div class=
"line"><span class=
"preprocessor">#include
<ctime
></span></div>
80 <div class=
"line"></div>
81 <div class=
"line"><span class=
"keywordtype">int
</span> main()
</div>
82 <div class=
"line">{
</div>
83 <div class=
"line"> <span class=
"keyword">using namespace
</span>boost::locale;
</div>
84 <div class=
"line"> <span class=
"keyword">using namespace
</span>std;
</div>
85 <div class=
"line"> </div>
86 <div class=
"line"> <span class=
"comment">// Create system default locale
</span></div>
87 <div class=
"line"> <a name=
"_a0"></a><a class=
"code" href=
"classboost_1_1locale_1_1generator.html">generator
</a> gen;
</div>
88 <div class=
"line"> locale loc=gen(
<span class=
"stringliteral">""</span>);
</div>
89 <div class=
"line"> locale::global(loc);
</div>
90 <div class=
"line"> wcout.imbue(loc);
</div>
91 <div class=
"line"> </div>
92 <div class=
"line"> <span class=
"comment">// This is needed to prevent C library to
</span></div>
93 <div class=
"line"> <span class=
"comment">// convert strings to narrow
</span></div>
94 <div class=
"line"> <span class=
"comment">// instead of C++ on some platforms
</span></div>
95 <div class=
"line"> std::ios_base::sync_with_stdio(
<span class=
"keyword">false
</span>);
</div>
96 <div class=
"line"></div>
97 <div class=
"line"> </div>
98 <div class=
"line"> wcout
<<<a name=
"a1"></a><a class=
"code" href=
"group__format.html#ga610f3ae827801febc962019cf82a2227">wformat
</a>(L
<span class=
"stringliteral">"Today {
1,date} at {
1,time} we had run our first localization example
"</span>) %
<a name=
"a2"></a><a class=
"code" href=
"group__manipulators.html#gae669b101cbeaed6f6d246ebdcaa8f39c">time
</a>(
0)
</div>
99 <div class=
"line"> <<endl;
</div>
100 <div class=
"line"> </div>
101 <div class=
"line"> wcout
<<L
<span class=
"stringliteral">"This is how we show numbers in this locale
"</span><<<a name=
"a3"></a><a class=
"code" href=
"group__manipulators.html#gaee05db73f5525d9a010cdc3aa02f634f">as::number
</a> << 103.34 <<endl;
</div>
102 <div class=
"line"> wcout
<<L
<span class=
"stringliteral">"This is how we show currency in this locale
"</span><<<a name=
"a4"></a><a class=
"code" href=
"group__manipulators.html#ga97c4997f9692834ea7b5ed3e8137d5fd">as::currency
</a> << 103.34 <<endl;
</div>
103 <div class=
"line"> wcout
<<L
<span class=
"stringliteral">"This is typical date in the locale
"</span><<<a name=
"a5"></a><a class=
"code" href=
"group__manipulators.html#gae05b82e6658dc573521518fed5f5c77f">as::date
</a> << <a class=
"code" href=
"group__manipulators.html#gae669b101cbeaed6f6d246ebdcaa8f39c">std::time
</a>(
0)
<<endl;
</div>
104 <div class=
"line"> wcout
<<L
<span class=
"stringliteral">"This is typical time in the locale
"</span><<<a class=
"code" href=
"group__manipulators.html#gae669b101cbeaed6f6d246ebdcaa8f39c">as::time
</a> << <a class=
"code" href=
"group__manipulators.html#gae669b101cbeaed6f6d246ebdcaa8f39c">std::time
</a>(
0)
<<endl;
</div>
105 <div class=
"line"> wcout
<<L
<span class=
"stringliteral">"This is upper case
"</span><<<a name=
"a6"></a><a class=
"code" href=
"group__convert.html#ga2ceae621801e8cf4f77c60d1e3047ae8">to_upper
</a>(L
<span class=
"stringliteral">"Hello World!
"</span>)
<<endl;
</div>
106 <div class=
"line"> wcout
<<L
<span class=
"stringliteral">"This is lower case
"</span><<<a name=
"a7"></a><a class=
"code" href=
"group__convert.html#ga4a3eb15f42f5cbae7bdd00c9e9cac222">to_lower
</a>(L
<span class=
"stringliteral">"Hello World!
"</span>)
<<endl;
</div>
107 <div class=
"line"> wcout
<<L
<span class=
"stringliteral">"This is title case
"</span><<<a name=
"a8"></a><a class=
"code" href=
"group__convert.html#ga684efb375e060c71cd3e1799a6329f7f">to_title
</a>(L
<span class=
"stringliteral">"Hello World!
"</span>)
<<endl;
</div>
108 <div class=
"line"> wcout
<<L
<span class=
"stringliteral">"This is fold case
"</span><<<a name=
"a9"></a><a class=
"code" href=
"group__convert.html#gadf59d16355babd955766deef89d470ea">fold_case
</a>(L
<span class=
"stringliteral">"Hello World!
"</span>)
<<endl;
</div>
109 <div class=
"line"> </div>
110 <div class=
"line">}
</div>
111 <div class=
"line"></div>
112 <div class=
"line"></div>
113 <div class=
"line"><span class=
"comment">// vim: tabstop=
4 expandtab shiftwidth=
4 softtabstop=
4</span></div>
114 </div><!-- fragment --> </div><!-- contents -->
115 </div><!-- doc-content -->
118 © 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.