<!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::util::base_converter Class Reference</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 class="current"><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 id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</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('classboost_1_1locale_1_1util_1_1base__converter.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-attribs">Static Public Attributes</a> &#124;
<a href="classboost_1_1locale_1_1util_1_1base__converter-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">boost::locale::util::base_converter Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>This class represent a simple stateless converter from UCS-4 and to UCS-4 for each single code point.  
 <a href="classboost_1_1locale_1_1util_1_1base__converter.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="util_8hpp_source.html">boost/locale/util.hpp</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ab2332b78e3e0c0b94ea3f6dafd123d60"><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#ab2332b78e3e0c0b94ea3f6dafd123d60">max_len</a> () const </td></tr>
<tr class="separator:ab2332b78e3e0c0b94ea3f6dafd123d60"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aadcc2c1a767f9d24972c6995e81c1315"><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aadcc2c1a767f9d24972c6995e81c1315">is_thread_safe</a> () const </td></tr>
<tr class="separator:aadcc2c1a767f9d24972c6995e81c1315"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a702b31840be6f5c540cd22ac75cb2349"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html">base_converter</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#a702b31840be6f5c540cd22ac75cb2349">clone</a> () const </td></tr>
<tr class="separator:a702b31840be6f5c540cd22ac75cb2349"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a27181b314e09f62ae9ea8fcd30d4e7c4"><td class="memItemLeft" align="right" valign="top">virtual uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#a27181b314e09f62ae9ea8fcd30d4e7c4">to_unicode</a> (char const *&amp;begin, char const *end)</td></tr>
<tr class="separator:a27181b314e09f62ae9ea8fcd30d4e7c4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afeecf1ee2699c26960cbf2d7d6d71d41"><td class="memItemLeft" align="right" valign="top">virtual uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#afeecf1ee2699c26960cbf2d7d6d71d41">from_unicode</a> (uint32_t u, char *begin, char const *end)</td></tr>
<tr class="separator:afeecf1ee2699c26960cbf2d7d6d71d41"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-attribs"></a>
Static Public Attributes</h2></td></tr>
<tr class="memitem:aa02e2dfd8ddc2b40a8705c6ea7fa8d48"><td class="memItemLeft" align="right" valign="top">static const uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa02e2dfd8ddc2b40a8705c6ea7fa8d48">illegal</a> =utf::illegal</td></tr>
<tr class="separator:aa02e2dfd8ddc2b40a8705c6ea7fa8d48"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa78dd2bae2783e31a00849a4e74aeb1e"><td class="memItemLeft" align="right" valign="top">static const uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aa78dd2bae2783e31a00849a4e74aeb1e">incomplete</a> =utf::incomplete</td></tr>
<tr class="separator:aa78dd2bae2783e31a00849a4e74aeb1e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This class represent a simple stateless converter from UCS-4 and to UCS-4 for each single code point. </p>
<p>This class is used for creation of std::codecvt facet for converting utf-16/utf-32 encoding to encoding supported by this converter</p>
<p>Please note, this converter should be fully stateless. Fully stateless means it should never assume that it is called in any specific order on the text. Even if the encoding itself seems to be stateless like windows-1255 or shift-jis, some encoders (most notably iconv) can actually compose several code-point into one or decompose them in case composite characters are found. So be very careful when implementing these converters for certain character set. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a702b31840be6f5c540cd22ac75cb2349"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html">base_converter</a>* boost::locale::util::base_converter::clone </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Create a polymorphic copy of this object, usually called only if <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#aadcc2c1a767f9d24972c6995e81c1315">is_thread_safe()</a> return false </p>

</div>
</div>
<a class="anchor" id="afeecf1ee2699c26960cbf2d7d6d71d41"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual uint32_t boost::locale::util::base_converter::from_unicode </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>u</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>begin</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char const *&#160;</td>
          <td class="paramname"><em>end</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Convert a single code-point <em>u</em> into encoding and store it in [begin,end) range.</p>
<p>If u is invalid Unicode code-point, or it can not be mapped correctly to represented character set, <em>illegal</em> should be returned</p>
<p>If u can be converted to a sequence of bytes c1, ... , cN (1&lt;= N &lt;= <a class="el" href="classboost_1_1locale_1_1util_1_1base__converter.html#ab2332b78e3e0c0b94ea3f6dafd123d60">max_len()</a> ) then</p>
<ol type="1">
<li>If end - begin &gt;= N, c1, ... cN are written starting at begin and N is returned</li>
<li>If end - begin &lt; N, incomplete is returned, it is unspecified what would be stored in bytes in range [begin,end) </li>
</ol>

</div>
</div>
<a class="anchor" id="aadcc2c1a767f9d24972c6995e81c1315"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool boost::locale::util::base_converter::is_thread_safe </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Returns true if calling the functions from_unicode, to_unicode, and max_len is thread safe.</p>
<p>Rule of thumb: if this class' implementation uses simple tables that are unchanged or is purely algorithmic like UTF-8 - so it does not share any mutable bit for independent to_unicode, from_unicode calls, you may set it to true, otherwise, for example if you use iconv_t descriptor or UConverter as conversion object return false, and this object will be cloned for each use. </p>

</div>
</div>
<a class="anchor" id="ab2332b78e3e0c0b94ea3f6dafd123d60"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual int boost::locale::util::base_converter::max_len </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Return the maximal length that one Unicode code-point can be converted to, for example for UTF-8 it is 4, for Shift-JIS it is 2 and ISO-8859-1 is 1 </p>

</div>
</div>
<a class="anchor" id="a27181b314e09f62ae9ea8fcd30d4e7c4"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual uint32_t boost::locale::util::base_converter::to_unicode </td>
          <td>(</td>
          <td class="paramtype">char const *&amp;&#160;</td>
          <td class="paramname"><em>begin</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char const *&#160;</td>
          <td class="paramname"><em>end</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Convert a single character starting at begin and ending at most at end to Unicode code-point.</p>
<p>if valid input sequence found in [<em>begin</em>,<em>code_point_end</em>) such as <em>begin</em> &lt; <em>code_point_end</em> &amp;&amp; <em>code_point_end</em> &lt;= <em>end</em> it is converted to its Unicode code point equivalent, <em>begin</em> is set to <em>code_point_end</em> </p>
<p>if incomplete input sequence found in [<em>begin</em>,<em>end</em>), i.e. there my be such <em>code_point_end</em> that <em>code_point_end</em> &gt; <em>end</em> and [<em>begin</em>, <em>code_point_end</em>) would be valid input sequence, then <em>incomplete</em> is returned begin stays unchanged, for example for UTF-8 conversion a *begin = 0xc2, <em>begin</em> +1 = <em>end</em> is such situation.</p>
<p>if invalid input sequence found, i.e. there is a sequence [<em>begin</em>, <em>code_point_end</em>) such as <em>code_point_end</em> &lt;= <em>end</em> that is illegal for this encoding, <em>illegal</em> is returned and begin stays unchanged. For example if *begin = 0xFF and begin &lt; end for UTF-8, then <em>illegal</em> is returned. </p>

</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a class="anchor" id="aa02e2dfd8ddc2b40a8705c6ea7fa8d48"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">const uint32_t boost::locale::util::base_converter::illegal =utf::illegal</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This value should be returned when an illegal input sequence or code-point is observed: For example if a UCS-32 code-point is in the range reserved for UTF-16 surrogates or an invalid UTF-8 sequence is found </p>

</div>
</div>
<a class="anchor" id="aa78dd2bae2783e31a00849a4e74aeb1e"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">const uint32_t boost::locale::util::base_converter::incomplete =utf::incomplete</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This value is returned in following cases: The of incomplete input sequence was found or insufficient output buffer was provided so complete output could not be written. </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>boost/locale/<a class="el" href="util_8hpp_source.html">util.hpp</a></li>
</ul>
</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>
