<!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: boost/locale/encoding_utf.hpp Source File</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&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;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 class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</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('encoding__utf_8hpp_source.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">encoding_utf.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">//  Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">//  Distributed under the Boost Software License, Version 1.0. (See</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">//  accompanying file LICENSE_1_0.txt or copy at</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment">//  http://www.boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#ifndef BOOST_LOCALE_ENCODING_UTF_HPP_INCLUDED</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define BOOST_LOCALE_ENCODING_UTF_HPP_INCLUDED</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &lt;boost/locale/utf.hpp&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;boost/locale/encoding_errors.hpp&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;iterator&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#ifdef BOOST_MSVC</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  pragma warning(push)</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#  pragma warning(disable : 4275 4251 4231 4660)</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="keyword">namespace </span>boost {</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <span class="keyword">namespace </span>locale {</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;        <span class="keyword">namespace </span>conv {</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;            <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharOut,<span class="keyword">typename</span> CharIn&gt;</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;            std::basic_string&lt;CharOut&gt;</div>
<div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="group__codepage.html#gaf0ad39959911b000706e0538ec059d44">   34</a></span>&#160;            <a class="code" href="group__codepage.html#gaf0ad39959911b000706e0538ec059d44">utf_to_utf</a>(CharIn <span class="keyword">const</span> *begin,CharIn <span class="keyword">const</span> *end,<a class="code" href="group__codepage.html#ga8e3c5a274f57107ec5745e227c26ba84">method_type</a> how = <a class="code" href="group__codepage.html#gga8e3c5a274f57107ec5745e227c26ba84adcdc34a57dd2a3ca917f73c13f18b559">default_method</a>)</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;            {</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;                std::basic_string&lt;CharOut&gt; result;</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;                result.reserve(end-begin);</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;                <span class="keyword">typedef</span> std::back_insert_iterator&lt;std::basic_string&lt;CharOut&gt; &gt; inserter_type;</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;                inserter_type inserter(result);</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;                <a class="code" href="namespaceboost_1_1locale_1_1utf.html#a068111a6b9d6d465a63893ed5c05e2f8">utf::code_point</a> c;</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;                <span class="keywordflow">while</span>(begin!=end) {</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;                    c=<a class="code" href="structboost_1_1locale_1_1utf_1_1utf__traits.html">utf::utf_traits&lt;CharIn&gt;::template</a> decode&lt;CharIn const *&gt;(begin,end);</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;                    <span class="keywordflow">if</span>(c==<a class="code" href="namespaceboost_1_1locale_1_1utf.html#a30010000878c7732340bda8956b844fb">utf::illegal</a> || c==<a class="code" href="namespaceboost_1_1locale_1_1utf.html#a20dbe458fd18229a0e6c09888d031b38">utf::incomplete</a>) {</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;                        <span class="keywordflow">if</span>(how==<a class="code" href="group__codepage.html#gga8e3c5a274f57107ec5745e227c26ba84aab08f9ee241c405ef40bd3cedb43b383">stop</a>)</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;                            <span class="keywordflow">throw</span> <a class="code" href="classboost_1_1locale_1_1conv_1_1conversion__error.html">conversion_error</a>();</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;                    }</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;                    <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;                        <a class="code" href="structboost_1_1locale_1_1utf_1_1utf__traits.html">utf::utf_traits&lt;CharOut&gt;::template</a> encode&lt;inserter_type&gt;(c,inserter);</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;                    }</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;                }</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;                <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;            }</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;            <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharOut,<span class="keyword">typename</span> CharIn&gt;</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;            std::basic_string&lt;CharOut&gt;</div>
<div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="group__codepage.html#gaa4de44e37cbe5ec4a4b79e1d9bbaf4a7">   59</a></span>&#160;            <a class="code" href="group__codepage.html#gaf0ad39959911b000706e0538ec059d44">utf_to_utf</a>(CharIn <span class="keyword">const</span> *str,<a class="code" href="group__codepage.html#ga8e3c5a274f57107ec5745e227c26ba84">method_type</a> how = <a class="code" href="group__codepage.html#gga8e3c5a274f57107ec5745e227c26ba84adcdc34a57dd2a3ca917f73c13f18b559">default_method</a>)</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;            {</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;                CharIn <span class="keyword">const</span> *end = str;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;                <span class="keywordflow">while</span>(*end)</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;                    end++;</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;                <span class="keywordflow">return</span> utf_to_utf&lt;CharOut,CharIn&gt;(str,end,how);</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;            }</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;            <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CharOut,<span class="keyword">typename</span> CharIn&gt;</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;            std::basic_string&lt;CharOut&gt;</div>
<div class="line"><a name="l00073"></a><span class="lineno"><a class="line" href="group__codepage.html#ga1951228e7f528a20e40258d73cf17f5c">   73</a></span>&#160;            <a class="code" href="group__codepage.html#gaf0ad39959911b000706e0538ec059d44">utf_to_utf</a>(std::basic_string&lt;CharIn&gt; <span class="keyword">const</span> &amp;str,<a class="code" href="group__codepage.html#ga8e3c5a274f57107ec5745e227c26ba84">method_type</a> how = <a class="code" href="group__codepage.html#gga8e3c5a274f57107ec5745e227c26ba84adcdc34a57dd2a3ca917f73c13f18b559">default_method</a>)</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;            {</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;                <span class="keywordflow">return</span> utf_to_utf&lt;CharOut,CharIn&gt;(str.c_str(),str.c_str()+str.size(),how);</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;            }</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;        } <span class="comment">// conv</span></div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    } <span class="comment">// locale</span></div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;} <span class="comment">// boost</span></div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="preprocessor">#ifdef BOOST_MSVC</span></div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#pragma warning(pop)</span></div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;<span class="comment">// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4</span></div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;</div>
<div class="ttc" id="namespaceboost_1_1locale_1_1utf_html_a20dbe458fd18229a0e6c09888d031b38"><div class="ttname"><a href="namespaceboost_1_1locale_1_1utf.html#a20dbe458fd18229a0e6c09888d031b38">boost::locale::utf::incomplete</a></div><div class="ttdeci">static const code_point incomplete</div><div class="ttdoc">Special constant that defines incomplete code point. </div><div class="ttdef"><b>Definition:</b> utf.hpp:44</div></div>
<div class="ttc" id="classboost_1_1locale_1_1conv_1_1conversion__error_html"><div class="ttname"><a href="classboost_1_1locale_1_1conv_1_1conversion__error.html">boost::locale::conv::conversion_error</a></div><div class="ttdoc">The excepton that is thrown in case of conversion error. </div><div class="ttdef"><b>Definition:</b> encoding_errors.hpp:31</div></div>
<div class="ttc" id="namespaceboost_1_1locale_1_1utf_html_a068111a6b9d6d465a63893ed5c05e2f8"><div class="ttname"><a href="namespaceboost_1_1locale_1_1utf.html#a068111a6b9d6d465a63893ed5c05e2f8">boost::locale::utf::code_point</a></div><div class="ttdeci">uint32_t code_point</div><div class="ttdoc">The integral type that can hold a Unicode code point. </div><div class="ttdef"><b>Definition:</b> utf.hpp:34</div></div>
<div class="ttc" id="namespaceboost_1_1locale_1_1utf_html_a30010000878c7732340bda8956b844fb"><div class="ttname"><a href="namespaceboost_1_1locale_1_1utf.html#a30010000878c7732340bda8956b844fb">boost::locale::utf::illegal</a></div><div class="ttdeci">static const code_point illegal</div><div class="ttdoc">Special constant that defines illegal code point. </div><div class="ttdef"><b>Definition:</b> utf.hpp:39</div></div>
<div class="ttc" id="structboost_1_1locale_1_1utf_1_1utf__traits_html"><div class="ttname"><a href="structboost_1_1locale_1_1utf_1_1utf__traits.html">boost::locale::utf::utf_traits</a></div><div class="ttdoc">UTF Traits class - functions to convert UTF sequences to and from Unicode code points. </div><div class="ttdef"><b>Definition:</b> utf.hpp:63</div></div>
<div class="ttc" id="group__codepage_html_gaf0ad39959911b000706e0538ec059d44"><div class="ttname"><a href="group__codepage.html#gaf0ad39959911b000706e0538ec059d44">boost::locale::conv::utf_to_utf</a></div><div class="ttdeci">std::basic_string&lt; CharOut &gt; utf_to_utf(CharIn const *begin, CharIn const *end, method_type how=default_method)</div><div class="ttdef"><b>Definition:</b> encoding_utf.hpp:34</div></div>
<div class="ttc" id="group__codepage_html_gga8e3c5a274f57107ec5745e227c26ba84adcdc34a57dd2a3ca917f73c13f18b559"><div class="ttname"><a href="group__codepage.html#gga8e3c5a274f57107ec5745e227c26ba84adcdc34a57dd2a3ca917f73c13f18b559">boost::locale::conv::default_method</a></div><div class="ttdoc">Default method - skip. </div><div class="ttdef"><b>Definition:</b> encoding_errors.hpp:57</div></div>
<div class="ttc" id="group__codepage_html_gga8e3c5a274f57107ec5745e227c26ba84aab08f9ee241c405ef40bd3cedb43b383"><div class="ttname"><a href="group__codepage.html#gga8e3c5a274f57107ec5745e227c26ba84aab08f9ee241c405ef40bd3cedb43b383">boost::locale::conv::stop</a></div><div class="ttdoc">Stop conversion and throw conversion_error. </div><div class="ttdef"><b>Definition:</b> encoding_errors.hpp:56</div></div>
<div class="ttc" id="group__codepage_html_ga8e3c5a274f57107ec5745e227c26ba84"><div class="ttname"><a href="group__codepage.html#ga8e3c5a274f57107ec5745e227c26ba84">boost::locale::conv::method_type</a></div><div class="ttdeci">method_type</div><div class="ttdef"><b>Definition:</b> encoding_errors.hpp:54</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->

    <li class="footer">
&copy; 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>
