1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4 <TITLE>Code Conversion</TITLE> 5 <LINK REL="stylesheet" href="../../../../boost.css"> 6 <LINK REL="stylesheet" href="../theme/iostreams.css"> 7</HEAD> 8<BODY> 9 10<!-- Begin Banner --> 11 12 <H1 CLASS="title">User's Guide</H1> 13 <HR CLASS="banner"> 14 15<!-- End Banner --> 16 17<!-- Begin Nav --> 18 19<DIV CLASS='nav'> 20 <A HREF='filtering_streams.html'><IMG BORDER=0 WIDTH=19 HEIGHT=19 SRC='../../../../doc/src/images/prev.png'></A> 21 <A HREF='guide.html'><IMG BORDER=0 WIDTH=19 HEIGHT=19 SRC='../../../../doc/src/images/up.png'></A> 22 <A HREF='asynchronous.html'><IMG BORDER=0 WIDTH=19 HEIGHT=19 SRC='../../../../doc/src/images/next.png'></A> 23</DIV> 24 25<!-- End Nav --> 26 27<A NAME="overview"></A> 28<H2>3.5 Code Conversion</H2> 29 30<HR STYLE="margin-top:1em"> 31 32<P> 33 The process of converting between a sequence of wide characters and a sequence of narrow characters is known as <SPAN CLASS='term'>code conversion</SPAN>. The C++ standard library defines a locale facet <CODE>std::codecvt</CODE> that encapulates code conversion. The class template <CODE>codecvt</CODE> has three template parameters, representing an <SPAN CLASS='term'>internal character type</SPAN>, an <SPAN CLASS='term'>external character type</SPAN> and a type to store a <SPAN CLASS='term'>code conversion state</SPAN>. The internal character type is so named because it is typically the type used to store wide characters in memory for processing by an application; the external character type is so named because it is typically the character type used to store charatcres in external media such as files. Most of the time, the internal character type is <CODE>wchar_t</CODE>, the external character type is <CODE>char</CODE> and the code conversion state is <CODE>std::mbstate_t</CODE>, an implementation-defined type specified by the C++ standard. 34</P> 35 36<P> 37 Streams and stream buffers do not perform code conversion by default. Of the streams and stream buffers defined in the C++ standard library, only the file-based streams perform code conversion. To write a stream or stream buffer that performs code conversion, use the class template <A HREF="../classes/code_converter.html"><CODE>code_converter</CODE></A>, which performs code conversion using a <CODE>std::codecvt</CODE> facet. 38</P> 39 40<!-- Begin Footer --> 41 42<HR> 43 44<P CLASS="copyright">© Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a><br/>© Copyright 2004-2007 <a href="https://www.boost.org/users/people/jonathan_turkanis.html" target="_top">Jonathan Turkanis</a></P> 45<P CLASS="copyright"> 46 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <A HREF="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>) 47</P> 48 49<!-- End Footer --> 50 51</BODY>