123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <!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: Collation</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 class="current"><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('collation.html','');});
- </script>
- <div id="doc-content">
- <div class="header">
- <div class="headertitle">
- <div class="title">Collation </div> </div>
- </div><!--header-->
- <div class="contents">
- <div class="textblock"><p>Boost.Locale provides a <a class="el" href="classboost_1_1locale_1_1collator.html">collator</a> class, derived from <code>std::collate</code>, that adds support for primary, secondary, tertiary, quaternary and identical comparison levels. They can be approximately defined as:</p>
- <ol type="1">
- <li>Primary – ignore accents and character case, comparing base letters only. For example "facade" and "Façade" are the same.</li>
- <li>Secondary – ignore character case but consider accents. "facade" and "façade" are different but "Façade" and "façade" are the same.</li>
- <li>Tertiary – consider both case and accents: "Façade" and "façade" are different. Ignore punctuation.</li>
- <li>Quaternary – consider all case, accents, and punctuation. The words must be identical in terms of Unicode representation.</li>
- <li>Identical – as quaternary, but compare code points as well.</li>
- </ol>
- <p>There are two ways of using the <a class="el" href="classboost_1_1locale_1_1collator.html">collator</a> facet: directly, by calling its member functions <a class="el" href="classboost_1_1locale_1_1collator.html#ab90dc7bb909a71d3cd9a5e8d7b2eb80e">compare</a>, <a class="el" href="classboost_1_1locale_1_1collator.html#a8dc6443fb193616332ca50f207a9b189">transform</a> and <a class="el" href="classboost_1_1locale_1_1collator.html#a89752e2023643f972b6cc8024340d5d4">hash</a>, or indirectly by using the <a class="el" href="structboost_1_1locale_1_1comparator.html">comparator</a> template class in STL algorithms.</p>
- <p>For example:</p>
- <div class="fragment"><div class="line">wstring a=L<span class="stringliteral">"Façade"</span>, b=L<span class="stringliteral">"facade"</span>;</div>
- <div class="line"><span class="keywordtype">bool</span> eq = 0 == use_facet<collator<wchar_t> >(loc).compare(collator_base::secondary,a,b);</div>
- <div class="line">wcout << a <<L<span class="stringliteral">" and "</span><<b<<L<span class="stringliteral">" are "</span> << (eq ? L<span class="stringliteral">"identical"</span> : L<span class="stringliteral">"different"</span>)<<endl;</div>
- </div><!-- fragment --><p><code>std::locale</code> is designed to be useful as a comparison class in STL collections and algorithms. To get similar functionality with comparison levels, you must use the comparator class.</p>
- <div class="fragment"><div class="line">std::map<std::string,std::string,comparator<char,collator_base::secondary> > strings;</div>
- <div class="line"><span class="comment">// Now strings uses the default system locale for string comparison</span></div>
- </div><!-- fragment --><p>You can also set a specific locale or level when creating and using the <a class="el" href="structboost_1_1locale_1_1comparator.html">comparator</a> class:</p>
- <div class="fragment"><div class="line">comparator<char> comp(some_locale,some_level);</div>
- <div class="line">std::map<std::string,std::string,comparator<char> > strings(comp);</div>
- </div><!-- fragment --> </div></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>
|