Imported Upstream version 1.49.0
[platform/upstream/boost.git] / libs / locale / doc / html / whello_8cpp-example.html
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 <title>Boost.Locale: whello.cpp</title>
6 <link href="tabs.css" rel="stylesheet" type="text/css"/>
7 <link href="doxygen.css" rel="stylesheet" type="text/css"/>
8 <link rel="stylesheet" type="text/css" href="../style/section-basic.css">
9 </head>
10 <body>
11 <div id="boost-common-heading-doc">
12     <div class="heading-inner">
13         <div class="heading-placard"></div>
14
15         <h1 class="heading-title">
16             <a href="http://www.boost.org/">
17                 <img src="../style/space.png" alt= "Boost C++ Libraries" class="heading-logo" />
18                 <span class="heading-boost">Boost</span>
19                 <span class="heading-cpplibraries">C++ Libraries</span>
20             </a>
21         </h1>
22
23         <p class="heading-quote">
24
25             <q>...one of the most highly
26             regarded and expertly designed C++ library projects in the
27             world.</q> 
28             
29             <span class="heading-attribution">&mdash; <a href=
30             "http://www.gotw.ca/" class="external">Herb Sutter</a> and <a href=
31             "http://en.wikipedia.org/wiki/Andrei_Alexandrescu" class="external">Andrei
32             Alexandrescu</a>, <a href=
33             "http://safari.awprofessional.com/?XmlId=0321113586" class="external">C++
34             Coding Standards</a></span>
35         </p>
36     </div>
37 </div>
38
39 <div id="boost-common-heading-doc-spacer"></div> 
40 <!-- Generated by Doxygen 1.7.1 -->
41 <div class="navigation" id="top">
42   <div class="tabs">
43     <ul class="tablist">
44       <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
45       <li><a href="modules.html"><span>Modules</span></a></li>
46       <li><a href="namespaces.html"><span>Namespaces</span></a></li>
47       <li><a href="annotated.html"><span>Classes</span></a></li>
48       <li><a href="files.html"><span>Files</span></a></li>
49       <li><a href="examples.html"><span>Examples</span></a></li>
50     </ul>
51   </div>
52 </div>
53 <div class="header">
54   <div class="headertitle">
55 <h1>whello.cpp</h1>  </div>
56 </div>
57 <div class="contents">
58 <p>Basic example of using various functions with wide strings provided by this library</p>
59 <div class="fragment"><pre class="fragment"><span class="comment">//</span>
60 <span class="comment">//  Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)</span>
61 <span class="comment">//</span>
62 <span class="comment">//  Distributed under the Boost Software License, Version 1.0. (See</span>
63 <span class="comment">//  accompanying file LICENSE_1_0.txt or copy at</span>
64 <span class="comment">//  http://www.boost.org/LICENSE_1_0.txt)</span>
65 <span class="comment">//</span>
66 <span class="preprocessor">#include &lt;boost/locale.hpp&gt;</span>
67 <span class="preprocessor">#include &lt;iostream&gt;</span>
68
69 <span class="preprocessor">#include &lt;ctime&gt;</span>
70
71 <span class="keywordtype">int</span> main()
72 {
73     <span class="keyword">using namespace </span>boost::locale;
74     <span class="keyword">using namespace </span>std;
75     
76     <span class="comment">// Create system default locale</span>
77     <a name="_a0"></a><a class="code" href="classboost_1_1locale_1_1generator.html" title="the major class used for locale generation">generator</a> gen;
78     locale loc=gen(<span class="stringliteral">&quot;&quot;</span>); 
79     locale::global(loc);
80     wcout.imbue(loc);
81     
82     <span class="comment">// This is needed to prevent C library to</span>
83     <span class="comment">// convert strings to narrow </span>
84     <span class="comment">// instead of C++ on some platforms</span>
85     std::ios_base::sync_with_stdio(<span class="keyword">false</span>);
86
87     
88     wcout &lt;&lt;<a name="a1"></a><a class="code" href="group__format.html#ga610f3ae827801febc962019cf82a2227">wformat</a>(L<span class="stringliteral">&quot;Today {1,date} at {1,time} we had run our first localization example&quot;</span>) % <a name="a2"></a><a class="code" href="group__manipulators.html#gae669b101cbeaed6f6d246ebdcaa8f39c">time</a>(0) 
89           &lt;&lt;endl;
90    
91     wcout&lt;&lt;L<span class="stringliteral">&quot;This is how we show numbers in this locale &quot;</span>&lt;&lt;<a name="a3"></a><a class="code" href="group__manipulators.html#gaee05db73f5525d9a010cdc3aa02f634f">as::number</a> &lt;&lt; 103.34 &lt;&lt;endl; 
92     wcout&lt;&lt;L<span class="stringliteral">&quot;This is how we show currency in this locale &quot;</span>&lt;&lt;<a name="a4"></a><a class="code" href="group__manipulators.html#ga97c4997f9692834ea7b5ed3e8137d5fd">as::currency</a> &lt;&lt; 103.34 &lt;&lt;endl; 
93     wcout&lt;&lt;L<span class="stringliteral">&quot;This is typical date in the locale &quot;</span>&lt;&lt;<a name="a5"></a><a class="code" href="group__manipulators.html#gae05b82e6658dc573521518fed5f5c77f">as::date</a> &lt;&lt; <a class="code" href="group__manipulators.html#gae669b101cbeaed6f6d246ebdcaa8f39c">std::time</a>(0) &lt;&lt;endl;
94     wcout&lt;&lt;L<span class="stringliteral">&quot;This is typical time in the locale &quot;</span>&lt;&lt;<a class="code" href="group__manipulators.html#gae669b101cbeaed6f6d246ebdcaa8f39c">as::time</a> &lt;&lt; <a class="code" href="group__manipulators.html#gae669b101cbeaed6f6d246ebdcaa8f39c">std::time</a>(0) &lt;&lt;endl;
95     wcout&lt;&lt;L<span class="stringliteral">&quot;This is upper case &quot;</span>&lt;&lt;<a name="a6"></a><a class="code" href="group__convert.html#ga7889a57e1bc1059fbb107db0781d0b6d">to_upper</a>(L<span class="stringliteral">&quot;Hello World!&quot;</span>)&lt;&lt;endl;
96     wcout&lt;&lt;L<span class="stringliteral">&quot;This is lower case &quot;</span>&lt;&lt;<a name="a7"></a><a class="code" href="group__convert.html#ga33de83f16ff2c09cac780977c6f67099">to_lower</a>(L<span class="stringliteral">&quot;Hello World!&quot;</span>)&lt;&lt;endl;
97     wcout&lt;&lt;L<span class="stringliteral">&quot;This is title case &quot;</span>&lt;&lt;<a name="a8"></a><a class="code" href="group__convert.html#ga646f42adb01baf395d632c32f556a5b9">to_title</a>(L<span class="stringliteral">&quot;Hello World!&quot;</span>)&lt;&lt;endl;
98     wcout&lt;&lt;L<span class="stringliteral">&quot;This is fold case &quot;</span>&lt;&lt;<a name="a9"></a><a class="code" href="group__convert.html#gabd1bc157122a5b9392487126fd0fffe5">fold_case</a>(L<span class="stringliteral">&quot;Hello World!&quot;</span>)&lt;&lt;endl;
99    
100 }
101
102
103 <span class="comment">// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4</span>
104 </pre></div> </div>
105 </div>
106 <hr class="footer"/><address class="footer"><small>
107 &copy; Copyright 2009-2011 Artyom Beilis,  Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License</a>, Version 1.0.
108 </small></address>
109 </body>
110 </html>