mirror of
https://github.com/boostorg/locale.git
synced 2026-02-26 04:42:21 +00:00
- Fixed issues with inspector - Changed the use of boost::mutex - not include entire boost.thread - Updated documentation build script [SVN r73059]
97 lines
5.9 KiB
HTML
97 lines
5.9 KiB
HTML
<!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"/>
|
|
<title>Boost.Locale: Collation</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
|
|
<!--
|
|
Switch the lines for stand alone version
|
|
<link rel="stylesheet" type="text/css" href="http://www.boost.org/style-v2/section-basic.css">
|
|
-->
|
|
<link rel="stylesheet" type="text/css" href="../style/section-basic.css">
|
|
</head>
|
|
<body>
|
|
<div id="boost-common-heading-doc">
|
|
<div class="heading-inner">
|
|
<div class="heading-placard"></div>
|
|
|
|
<h1 class="heading-title">
|
|
<a href="http://www.boost.org/">
|
|
<!--
|
|
Switch the lines for stand alone version
|
|
<img src="http://www.boost.org/gfx/space.png" alt= "Boost C++ Libraries" class="heading-logo" />
|
|
-->
|
|
<img src="../style/space.png" alt= "Boost C++ Libraries" class="heading-logo" />
|
|
<span class="heading-boost">Boost</span>
|
|
<span class="heading-cpplibraries">C++ Libraries</span>
|
|
</a>
|
|
</h1>
|
|
|
|
<p class="heading-quote">
|
|
|
|
<q>...one of the most highly
|
|
regarded and expertly designed C++ library projects in the
|
|
world.</q>
|
|
|
|
<span class="heading-attribution">— <a href=
|
|
"http://www.gotw.ca/" class="external">Herb Sutter</a> and <a href=
|
|
"http://en.wikipedia.org/wiki/Andrei_Alexandrescu" class="external">Andrei
|
|
Alexandrescu</a>, <a href=
|
|
"http://safari.awprofessional.com/?XmlId=0321113586" class="external">C++
|
|
Coding Standards</a></span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="boost-common-heading-doc-spacer"></div>
|
|
<!-- Generated by Doxygen 1.7.1 -->
|
|
<div class="navigation" id="top">
|
|
<div class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="main.html"><span>Main Page</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 class="navpath">
|
|
<ul>
|
|
<li><a class="el" href="main.html">Boost.Locale</a> </li>
|
|
<li><a class="el" href="using_boost_locale.html">Using Boost.Locale</a> </li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<h1>Collation </h1> </div>
|
|
</div>
|
|
<div class="contents">
|
|
<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"><pre class="fragment"> wstring a=L<span class="stringliteral">"Façade"</span>, b=L<span class="stringliteral">"facade"</span>;
|
|
<span class="keywordtype">bool</span> eq = 0 == use_facet<collator<wchar_t> >(loc).compare(collator_base::secondary,a,b);
|
|
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;
|
|
</pre></div><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"><pre class="fragment"> std::map<std::string,std::string,comparator<char,collator_base::secondary> > strings;
|
|
<span class="comment">// Now strings uses the default system locale for string comparison</span>
|
|
</pre></div><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"><pre class="fragment"> comparator<char> comp(some_locale,some_level);
|
|
std::map<std::string,std::string,comparator<char> > strings(comp);
|
|
</pre></div> </div>
|
|
<hr class="footer"/><address class="footer"><small>
|
|
© 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.
|
|
</small></address>
|
|
</body>
|
|
</html>
|