123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=9"/>
- <meta name="generator" content="Doxygen 1.8.6"/>
- <title>Boost.Locale: conversions.cpp</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript" src="dynsections.js"></script>
- <link href="navtree.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="resize.js"></script>
- <script type="text/javascript" src="navtree.js"></script>
- <script type="text/javascript">
- $(document).ready(initResizable);
- $(window).load(resizeHeight);
- </script>
- <link href="doxygen.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
- <div id="titlearea">
- <table cellspacing="0" cellpadding="0">
- <tbody>
- <tr style="height: 56px;">
- <td id="projectlogo"><img alt="Logo" src="boost-small.png"/></td>
- <td style="padding-left: 0.5em;">
- <div id="projectname">Boost.Locale
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <!-- Generated by Doxygen 1.8.6 -->
- <div id="navrow1" class="tabs">
- <ul class="tablist">
- <li><a href="index.html"><span>Main Page</span></a></li>
- <li><a href="pages.html"><span>Related Pages</span></a></li>
- <li><a href="modules.html"><span>Modules</span></a></li>
- <li><a href="namespaces.html"><span>Namespaces</span></a></li>
- <li><a href="annotated.html"><span>Classes</span></a></li>
- <li><a href="files.html"><span>Files</span></a></li>
- <li><a href="examples.html"><span>Examples</span></a></li>
- </ul>
- </div>
- </div><!-- top -->
- <div id="side-nav" class="ui-resizable side-nav-resizable">
- <div id="nav-tree">
- <div id="nav-tree-contents">
- <div id="nav-sync" class="sync"></div>
- </div>
- </div>
- <div id="splitbar" style="-moz-user-select:none;"
- class="ui-resizable-handle">
- </div>
- </div>
- <script type="text/javascript">
- $(document).ready(function(){initNavTree('conversions_8cpp-example.html','');});
- </script>
- <div id="doc-content">
- <div class="header">
- <div class="headertitle">
- <div class="title">conversions.cpp</div> </div>
- </div><!--header-->
- <div class="contents">
- <p>Example of using various text conversion functions.</p>
- <div class="fragment"><div class="line"><span class="comment">//</span></div>
- <div class="line"><span class="comment">// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)</span></div>
- <div class="line"><span class="comment">//</span></div>
- <div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0. (See</span></div>
- <div class="line"><span class="comment">// accompanying file LICENSE_1_0.txt or copy at</span></div>
- <div class="line"><span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span></div>
- <div class="line"><span class="comment">//</span></div>
- <div class="line"><span class="preprocessor">#include <boost/locale.hpp></span></div>
- <div class="line"><span class="preprocessor">#include <boost/algorithm/string/case_conv.hpp></span></div>
- <div class="line"><span class="preprocessor">#include <iostream></span></div>
- <div class="line"></div>
- <div class="line"><span class="preprocessor">#include <ctime></span></div>
- <div class="line"></div>
- <div class="line"></div>
- <div class="line"></div>
- <div class="line"><span class="keywordtype">int</span> main()</div>
- <div class="line">{</div>
- <div class="line"> <span class="keyword">using namespace </span>boost::locale;</div>
- <div class="line"> <span class="keyword">using namespace </span>std;</div>
- <div class="line"> <span class="comment">// Create system default locale</span></div>
- <div class="line"> <a name="_a0"></a><a class="code" href="classboost_1_1locale_1_1generator.html">generator</a> gen;</div>
- <div class="line"> locale loc=gen(<span class="stringliteral">""</span>); </div>
- <div class="line"> locale::global(loc); </div>
- <div class="line"> cout.imbue(loc);</div>
- <div class="line"></div>
- <div class="line"> </div>
- <div class="line"> cout<<<span class="stringliteral">"Correct case conversion can't be done by simple, character by character conversion"</span><<endl;</div>
- <div class="line"> cout<<<span class="stringliteral">"because case conversion is context sensitive and not 1-to-1 conversion"</span><<endl;</div>
- <div class="line"> cout<<<span class="stringliteral">"For example:"</span><<endl;</div>
- <div class="line"> cout<<<span class="stringliteral">" German grüßen correctly converted to "</span><<<a name="a1"></a><a class="code" href="group__convert.html#ga2ceae621801e8cf4f77c60d1e3047ae8">to_upper</a>(<span class="stringliteral">"grüßen"</span>)<<<span class="stringliteral">", instead of incorrect "</span></div>
- <div class="line"> <<boost::to_upper_copy(std::string(<span class="stringliteral">"grüßen"</span>))<<endl;</div>
- <div class="line"> cout<<<span class="stringliteral">" where ß is replaced with SS"</span><<endl;</div>
- <div class="line"> cout<<<span class="stringliteral">" Greek ὈΔΥΣΣΕΎΣ is correctly converted to "</span><<<a name="a2"></a><a class="code" href="group__convert.html#ga4a3eb15f42f5cbae7bdd00c9e9cac222">to_lower</a>(<span class="stringliteral">"ὈΔΥΣΣΕΎΣ"</span>)<<<span class="stringliteral">", instead of incorrect "</span></div>
- <div class="line"> <<boost::to_lower_copy(std::string(<span class="stringliteral">"ὈΔΥΣΣΕΎΣ"</span>))<<endl;</div>
- <div class="line"> cout<<<span class="stringliteral">" where Σ is converted to σ or to ς, according to position in the word"</span><<endl;</div>
- <div class="line"> cout<<<span class="stringliteral">"Such type of conversion just can't be done using std::toupper that work on character base, also std::toupper is "</span><<endl;</div>
- <div class="line"> cout<<<span class="stringliteral">"not even applicable when working with variable character length like in UTF-8 or UTF-16 limiting the correct "</span><<endl;</div>
- <div class="line"> cout<<<span class="stringliteral">"behavior to unicode subset BMP or ASCII only"</span><<endl;</div>
- <div class="line"> </div>
- <div class="line">}</div>
- <div class="line"></div>
- <div class="line"><span class="comment">// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4</span></div>
- <div class="line"></div>
- <div class="line"><span class="comment">// boostinspect:noascii</span></div>
- </div><!-- fragment --> </div><!-- contents -->
- </div><!-- doc-content -->
- <li class="footer">
- © 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.
- </li>
- </ul>
- </div>
- </body>
- </html>
|