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 <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">
11 <div id="boost-common-heading-doc">
12 <div class="heading-inner">
13 <div class="heading-placard"></div>
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>
23 <p class="heading-quote">
25 <q>...one of the most highly
26 regarded and expertly designed C++ library projects in the
29 <span class="heading-attribution">— <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>
39 <div id="boost-common-heading-doc-spacer"></div>
40 <!-- Generated by Doxygen 1.7.1 -->
41 <div class="navigation" id="top">
44 <li><a href="main.html"><span>Main 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>
54 <div class="headertitle">
55 <h1>whello.cpp</h1> </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 <boost/locale.hpp></span>
67 <span class="preprocessor">#include <iostream></span>
69 <span class="preprocessor">#include <ctime></span>
71 <span class="keywordtype">int</span> main()
73 <span class="keyword">using namespace </span>boost::locale;
74 <span class="keyword">using namespace </span>std;
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">""</span>);
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>);
88 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)
91 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;
92 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;
93 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;
94 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;
95 wcout<<L<span class="stringliteral">"This is upper case "</span><<<a name="a6"></a><a class="code" href="group__convert.html#ga7889a57e1bc1059fbb107db0781d0b6d">to_upper</a>(L<span class="stringliteral">"Hello World!"</span>)<<endl;
96 wcout<<L<span class="stringliteral">"This is lower case "</span><<<a name="a7"></a><a class="code" href="group__convert.html#ga33de83f16ff2c09cac780977c6f67099">to_lower</a>(L<span class="stringliteral">"Hello World!"</span>)<<endl;
97 wcout<<L<span class="stringliteral">"This is title case "</span><<<a name="a8"></a><a class="code" href="group__convert.html#ga646f42adb01baf395d632c32f556a5b9">to_title</a>(L<span class="stringliteral">"Hello World!"</span>)<<endl;
98 wcout<<L<span class="stringliteral">"This is fold case "</span><<<a name="a9"></a><a class="code" href="group__convert.html#gabd1bc157122a5b9392487126fd0fffe5">fold_case</a>(L<span class="stringliteral">"Hello World!"</span>)<<endl;
103 <span class="comment">// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4</span>
106 <hr class="footer"/><address class="footer"><small>
107 © 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.