Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 1925

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/codecs/qtextcodec.cpp:171 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QTextCodec Class</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QTextCodec Class Reference</h1>

<p>The QTextCodec class provides conversion between text encodings.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qtextcodec-h.html">qtextcodec.h</a>&gt;</tt>
<p>Inherited by <a href="qeucjpcodec.html">QEucJpCodec</a>, <a href="qeuckrcodec.html">QEucKrCodec</a>, <a href="qgbkcodec.html">QGbkCodec</a>, <a href="qjiscodec.html">QJisCodec</a>, <a href="qhebrewcodec.html">QHebrewCodec</a>, <a href="qsjiscodec.html">QSjisCodec</a> and <a href="qtsciicodec.html">QTsciiCodec</a>.
<p><a href="qtextcodec-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn>virtual <a href="#~QTextCodec"><b>~QTextCodec</b></a> ()</div></li>
<li><div class=fn>virtual const char * <a href="#name"><b>name</b></a> () const = 0</div></li>
<li><div class=fn>virtual const char * <a href="#mimeName"><b>mimeName</b></a> () const</div></li>
<li><div class=fn>virtual int <a href="#mibEnum"><b>mibEnum</b></a> () const = 0</div></li>
<li><div class=fn>virtual QTextDecoder * <a href="#makeDecoder"><b>makeDecoder</b></a> () const</div></li>
<li><div class=fn>virtual QTextEncoder * <a href="#makeEncoder"><b>makeEncoder</b></a> () const</div></li>
<li><div class=fn>virtual QString <a href="#toUnicode"><b>toUnicode</b></a> ( const&nbsp;char&nbsp;*&nbsp;chars, int&nbsp;len ) const</div></li>
<li><div class=fn>virtual QCString <a href="#fromUnicode"><b>fromUnicode</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;uc, int&nbsp;&amp;&nbsp;lenInOut ) const</div></li>
<li><div class=fn>QCString <a href="#fromUnicode-2"><b>fromUnicode</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;uc ) const</div></li>
<li><div class=fn>QString <a href="#toUnicode-2"><b>toUnicode</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;a, int&nbsp;len ) const</div></li>
<li><div class=fn>QString <a href="#toUnicode-3"><b>toUnicode</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;a ) const</div></li>
<li><div class=fn>QString <a href="#toUnicode-4"><b>toUnicode</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;a, int&nbsp;len ) const</div></li>
<li><div class=fn>QString <a href="#toUnicode-5"><b>toUnicode</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;a ) const</div></li>
<li><div class=fn>QString <a href="#toUnicode-6"><b>toUnicode</b></a> ( const&nbsp;char&nbsp;*&nbsp;chars ) const</div></li>
<li><div class=fn>virtual bool <a href="#canEncode"><b>canEncode</b></a> ( QChar&nbsp;ch ) const</div></li>
<li><div class=fn>virtual bool <a href="#canEncode-2"><b>canEncode</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;s ) const</div></li>
<li><div class=fn>virtual int <a href="#heuristicContentMatch"><b>heuristicContentMatch</b></a> ( const&nbsp;char&nbsp;*&nbsp;chars, int&nbsp;len ) const = 0</div></li>
<li><div class=fn>virtual int <a href="#heuristicNameMatch"><b>heuristicNameMatch</b></a> ( const&nbsp;char&nbsp;*&nbsp;hint ) const</div></li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class=fn>QTextCodec * <a href="#loadCharmap"><b>loadCharmap</b></a> ( QIODevice&nbsp;*&nbsp;iod )</div></li>
<li><div class=fn>QTextCodec * <a href="#loadCharmapFile"><b>loadCharmapFile</b></a> ( QString&nbsp;filename )</div></li>
<li><div class=fn>QTextCodec * <a href="#codecForMib"><b>codecForMib</b></a> ( int&nbsp;mib )</div></li>
<li><div class=fn>QTextCodec * <a href="#codecForName"><b>codecForName</b></a> ( const&nbsp;char&nbsp;*&nbsp;name, int&nbsp;accuracy = 0 )</div></li>
<li><div class=fn>QTextCodec * <a href="#codecForContent"><b>codecForContent</b></a> ( const&nbsp;char&nbsp;*&nbsp;chars, int&nbsp;len )</div></li>
<li><div class=fn>QTextCodec * <a href="#codecForIndex"><b>codecForIndex</b></a> ( int&nbsp;i )</div></li>
<li><div class=fn>QTextCodec * <a href="#codecForLocale"><b>codecForLocale</b></a> ()</div></li>
<li><div class=fn>void <a href="#setCodecForLocale"><b>setCodecForLocale</b></a> ( QTextCodec&nbsp;*&nbsp;c )</div></li>
<li><div class=fn>void <a href="#deleteAllCodecs"><b>deleteAllCodecs</b></a> ()</div></li>
<li><div class=fn>const char * <a href="#locale"><b>locale</b></a> ()</div></li>
</ul>
<h2>Protected Members</h2>
<ul>
<li><div class=fn><a href="#QTextCodec"><b>QTextCodec</b></a> ()</div></li>
</ul>
<h2>Static Protected Members</h2>
<ul>
<li><div class=fn>int <a href="#simpleHeuristicNameMatch"><b>simpleHeuristicNameMatch</b></a> ( const&nbsp;char&nbsp;*&nbsp;name, const&nbsp;char&nbsp;*&nbsp;hint )</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QTextCodec class provides conversion between text encodings.

<p> Qt uses Unicode to store, draw and manipulate strings. In many
situations you may wish to deal with data that uses a different
encoding. For example, most japanese documents are still stored in
Shift-JIS or ISO2022, while Russian users often have their documents
in koi8-r or CP1251.
<p> Qt provides a set of QTextCodec classes to help with converting
non-Unicode formats from and to Unicode. You can also create your
own codec classes (<a href="#subclassing">see later</a>).
<p> The supported encodings are:
<ul>
<li> Big5 (Chinese encoding)
<li> eucJP (one of the many Japanese encodings)
<li> eucKR (Korean)
<li> GBK (Chinese encoding)
<li> JIS7 (Japanese)
<li> Shift-JIS (Japanese)
<li> TSCII (Tamil)
<li> utf8 (Unicode, 8bit)
<li> utf16 (Unicode)
<li> KOI8-R (Russian)
<li> KOI8-U (Ukrainian)
<li> ISO8859-1 (Western)
<li> ISO8859-2 (Central Europe)
<li> ISO8859-3 (Central Europe)
<li> ISO8859-4 (Baltic)
<li> ISO8859-5 (Cyrillic)
<li> ISO8859-6 (Arabic)
<li> ISO8859-7 (Greek)
<li> ISO8859-8 (Hebrew, visually ordered)
<li> ISO8859-8-i (Hebrew, logically ordered)
<li> ISO8859-9 (Turkish)
<li> ISO8859-10
<li> ISO8859-13
<li> ISO8859-14
<li> ISO8859-15 (Western)
<li> CP 874
<li> CP 1250 (Central Europe)
<li> CP 1251 (Cyrillic)
<li> CP 1252 (Western)
<li> CP 1253 (Greek)
<li> CP 1254 (Turkish)
<li> CP 1255 (Hebrew)
<li> CP 1256 (Arabic)
<li> CP 1257 (Baltic)
<li> CP 1258
<li> Apple Roman
<li> TIS-620 (Thai)
</ul>
<p> QTextCodecs can be used as follows to convert some locally encoded
string to Unicode. Suppose you have some string encoded in russian
KOI8-R encoding, and want to convert it to Unicode. The simple way
to do this is:
<p> <pre>
  <a href="qcstring.html">QCString</a> locallyEncoded = "..."; // text to convert
  QTextCodec *codec = QTextCodec::<a href="#codecForName">codecForName</a>("KOI8-R"); // get the codec for KOI8-R
  <a href="qstring.html">QString</a> unicodeString = codec-&gt;<a href="#toUnicode">toUnicode</a>( locallyEncoded );
  </pre>
 
<p> After this, <tt>unicodeString</tt> holds the text converted to Unicode.
Converting a string from Unicode to the local encoding is as simple:
<p> <pre>
  <a href="qstring.html">QString</a> unicodeString = ...;
  QTextCodec *codec = QTextCodec::<a href="#codecForName">codecForName</a>("KOI8-R"); // get the codec for KOI8-R
  <a href="qcstring.html">QCString</a> locallyEncoded = codec-&gt;<a href="#fromUnicode">fromUnicode</a>( unicodeString );
  </pre>
 
<p> Some care has to be taken when trying to convert the data in chunks
(for example when receiving it over a network). In this case the
above approach is too simplistic, because some encodings use more
than one byte per character. In this case a character could be split
between two chunks of data that are to be converted to Unicode, and
the above approach would, at best, lose one character and in some
other cases fail completely.
<p> The approach to use in these situations is to create a <a href="qtextdecoder.html">QTextDecoder</a>
object for the codec and use this QTextDecoder for the whole
decoding process, as shown below:
<p> <pre>
  QTextCodec *c = QTextCodec::<a href="#codecForName">codecForName</a>( "Shift-JIS" );
  <a href="qtextdecoder.html">QTextDecoder</a> *decoder = c-&gt;<a href="#makeDecoder">makeDecoder</a>();

  <a href="qstring.html">QString</a> unicodeString;
  while( receiving_data ) {
      <a href="qbytearray.html">QByteArray</a> chunk = new_data;
      unicodeString += decoder-&gt;<a href="qtextdecoder.html#toUnicode">toUnicode</a>( chunk.<a href="qmemarray.html#data">data</a>(), chunk.length() );
  }
  </pre>
 
<p> The QTextDecoder object maintains state between chunks and therefore
works correctly even if a multi-byte character is split between
chunks.
<p> <a name="subclassing"></a>
<h3> Creating your own Codec class
</h3>
<a name="1"></a><p> By making objects of subclasses of QTextCodec, support for
new text encodings can be added to Qt.
<p> You may find it more convenient to make your codec class available
as a plugin; see the <a href="plugins-howto.html">plugin
  documentation</a> for more details.
<p> The abstract virtual functions describe the encoder to the
system and the coder is used as required in the different
text file formats supported by <a href="qtextstream.html">QTextStream</a>, and under X11, for the
locale-specific character input and output.
<p> More recently created QTextCodec objects take precedence
over earlier ones.
<p> To add support for another 8-bit encoding to Qt, make a subclass
of QTextCodec and implement at least the following methods:
<p> <pre>
   const char* name() const
   </pre>
 
Return the official name for the encoding.
<p> <pre>
   int mibEnum() const
   </pre>
 
Return the MIB enum for the encoding if it is listed in the
<a href="http://www.iana.org/assignments/character-sets">IANA character-sets encoding file</a>.
<p> If the encoding is multi-byte then it will have "state"; that is,
the interpretation of some bytes will be dependent on some preceding
bytes.  For such an encoding, you will need to implement:
<p> <pre>
   <a href="qtextdecoder.html">QTextDecoder</a>* makeDecoder() const
   </pre>
 
Return a <a href="qtextdecoder.html">QTextDecoder</a> that remembers incomplete multibyte
sequence prefixes or other required state.
<p> If the encoding does <em>not</em> require state, you should implement:
<p> <pre>
   <a href="qstring.html">QString</a> toUnicode(const char* chars, int len) const
   </pre>
 
Converts <em>len</em> characters from <em>chars</em> to Unicode.
<p> The base QTextCodec class has default implementations of the above
two functions, <i>but they are mutually recursive</i>, so you must
re-implement at least one of them, or both for improved efficiency.
<p> For conversion from Unicode to 8-bit encodings, it is rarely necessary
to maintain state.  However, two functions similar to the two above
are used for encoding:
<p> <pre>
   <a href="qtextencoder.html">QTextEncoder</a>* makeEncoder() const
   </pre>
 
Return a QTextDecoder.
<p> <pre>
   <a href="qcstring.html">QCString</a> fromUnicode(const <a href="qstring.html">QString</a>&amp; uc, int&amp; lenInOut ) const
   </pre>
 
Converts <em>lenInOut</em> characters (of type <a href="qchar.html">QChar</a>) from the start
of the string <em>uc</em>, returning a <a href="qcstring.html">QCString</a> result, and also returning
the <a href="qcstring.html#length">length</a>
of the result in lenInOut.
<p> Again, these are mutually recursive so only one needs to be implemented,
or both if better efficiency is possible.
<p> Finally, you must implement:
<p> <pre>
   int heuristicContentMatch(const char* chars, int len) const
   </pre>
 
Gives a value indicating how likely it is that <em>len</em> characters
from <em>chars</em> are in the encoding.
<p> A good model for this function is the
QWindowsLocalCodec::heuristicContentMatch function found in the Qt sources.
<p> A QTextCodec subclass might have improved performance if you also
re-implement:
<p> <pre>
   bool canEncode( <a href="qchar.html">QChar</a> ) const
   </pre>
 
Test if a Unicode character can be encoded.
<p> <pre>
   bool canEncode( const <a href="qstring.html">QString</a>&amp; ) const
   </pre>
 
Test if a string of Unicode characters can be encoded.
<p> <pre>
   int heuristicNameMatch(const char* hint) const
   </pre>
 
Test if a possibly non-standard name is referring to the codec.
<p> Codecs can also be created as <a href="plugins-howto.html">plugins</a>.
<p>See also <a href="i18n.html">Internationalization with Qt</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QTextCodec"></a>QTextCodec::QTextCodec ()<tt> [protected]</tt>
</h3>
Constructs a QTextCodec, and gives it the highest precedence.
The QTextCodec should always be constructed on the heap
(i.e. with new()), and once constructed it becomes the responsibility
of Qt to delete it (which is done at <a href="qapplication.html">QApplication</a> destruction).

<h3 class=fn><a name="~QTextCodec"></a>QTextCodec::~QTextCodec ()<tt> [virtual]</tt>
</h3>
Destroys the QTextCodec.  Note that you should not delete
codecs yourself: once created they become Qt's responsibility.

<h3 class=fn>bool <a name="canEncode"></a>QTextCodec::canEncode ( <a href="qchar.html">QChar</a>&nbsp;ch ) const<tt> [virtual]</tt>
</h3>
Returns TRUE if the unicode character <em>ch</em> can be fully encoded
with this codec; otherwise returns FALSE.  The default
implementation tests if the result of <a href="#toUnicode">toUnicode</a>(fromUnicode(ch)) is
the original <em>ch</em>. Subclasses may be able to improve the
efficiency.

<h3 class=fn>bool <a name="canEncode-2"></a>QTextCodec::canEncode ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;s ) const<tt> [virtual]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <em>s</em> contains the string being tested for encode-ability.

<h3 class=fn><a href="qtextcodec.html">QTextCodec</a>&nbsp;* <a name="codecForContent"></a>QTextCodec::codecForContent ( const&nbsp;char&nbsp;*&nbsp;chars, int&nbsp;len )<tt> [static]</tt>
</h3>
Searches all installed QTextCodec objects, returning the one
which most recognizes the given content.  May return 0.
<p> Note that this is often a poor choice, since character
encodings often use most of the available character sequences,
and so only by linguistic analysis could a true match be made.
<p> <em>chars</em> contains the string to check, and <em>len</em> contains the
number of characters in the string to use.
<p> <p>See also <a href="#heuristicContentMatch">heuristicContentMatch</a>().

<p>Example: <a href="qwerty-example.html#x653">qwerty/qwerty.cpp</a>.
<h3 class=fn><a href="qtextcodec.html">QTextCodec</a>&nbsp;* <a name="codecForIndex"></a>QTextCodec::codecForIndex ( int&nbsp;i )<tt> [static]</tt>
</h3>
Returns the QTextCodec <em>i</em> positions from the most recently
inserted codec, or 0 if there is no such QTextCodec.  Thus,
<a href="#codecForIndex">codecForIndex</a>(0) returns the most recently created QTextCodec.

<p>Example: <a href="qwerty-example.html#x654">qwerty/qwerty.cpp</a>.
<h3 class=fn><a href="qtextcodec.html">QTextCodec</a>&nbsp;* <a name="codecForLocale"></a>QTextCodec::codecForLocale ()<tt> [static]</tt>
</h3>  Returns a pointer to the codec most suitable for this locale. 
<p>Example: <a href="qwerty-example.html#x655">qwerty/qwerty.cpp</a>.
<h3 class=fn><a href="qtextcodec.html">QTextCodec</a>&nbsp;* <a name="codecForMib"></a>QTextCodec::codecForMib ( int&nbsp;mib )<tt> [static]</tt>
</h3>
Returns the QTextCodec which matches the
<a href="#mibEnum">MIBenum</a> <em>mib</em>.

<h3 class=fn><a href="qtextcodec.html">QTextCodec</a>&nbsp;* <a name="codecForName"></a>QTextCodec::codecForName ( const&nbsp;char&nbsp;*&nbsp;name, int&nbsp;accuracy = 0 )<tt> [static]</tt>
</h3>
Searches all installed QTextCodec objects and returns the one
which best matches <em>name</em>.  Returns a null pointer if no codec's
<a href="#heuristicNameMatch">heuristicNameMatch</a>() reports a match better than <em>accuracy</em>, or
if <em>name</em> is a null string.
<p> <p>See also <a href="#heuristicNameMatch">heuristicNameMatch</a>().

<h3 class=fn>void <a name="deleteAllCodecs"></a>QTextCodec::deleteAllCodecs ()<tt> [static]</tt>
</h3>  Deletes all the created codecs.
<p> <b>Warning:</b> Do not call this function.
<p> <a href="qapplication.html">QApplication</a> calls this just before exiting, to delete any
QTextCodec objects that may be lying around.  Since various other
classes hold pointers to QTextCodec objects, it is not safe to call
this function earlier.
<p> If you are using the utility classes (like <a href="qstring.html">QString</a>) but not using
QApplication, calling this function at the very end of your
application can be helpful to chase down memory leaks, as
QTextCodec objects will not show up.

<h3 class=fn><a href="qcstring.html">QCString</a> <a name="fromUnicode"></a>QTextCodec::fromUnicode ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;uc, int&nbsp;&amp;&nbsp;lenInOut ) const<tt> [virtual]</tt>
</h3>
Subclasses of QTextCodec must reimplement either this function or
<a href="#makeEncoder">makeEncoder</a>().  It converts the first <em>lenInOut</em> characters of <em>uc</em> from Unicode to the encoding of the subclass.  If <em>lenInOut</em>
is negative or too large, the length of <em>uc</em> is used instead.
<p> The value returned is owned by the caller, which is
responsible for deleting it with "delete []".  The length of the
resulting Unicode character sequence is returned in <em>lenInOut</em>.
<p> The default implementation makes an encoder with makeEncoder() and
converts the input with that.  Note that the default makeEncoder()
implementation makes an encoder that simply calls
this function, hence subclasses <em>must</em> reimplement one function or
the other to avoid infinite recursion.

<p>Reimplemented in <a href="qhebrewcodec.html#fromUnicode">QHebrewCodec</a>.
<h3 class=fn><a href="qcstring.html">QCString</a> <a name="fromUnicode-2"></a>QTextCodec::fromUnicode ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;uc ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <em>uc</em> is the unicode source string.

<h3 class=fn>int <a name="heuristicContentMatch"></a>QTextCodec::heuristicContentMatch ( const&nbsp;char&nbsp;*&nbsp;chars, int&nbsp;len ) const<tt> [pure virtual]</tt>
</h3>

<p> Subclasses of QTextCodec must reimplement this function.  It examines
the first <em>len</em> bytes of <em>chars</em> and returns a value indicating how
likely it is that the string is a prefix of text encoded in the
encoding of the subclass.  A negative return value indicates that
the text is detectably not in the encoding (e.g. it contains
characters undefined in the encoding). A return value of 0 indicates
that the text should be decoded with this codec rather than as
ASCII, but there is no particular evidence.  The value should range
up to <em>len</em>.  Thus, most decoders will return -1, 0, or -<em>len</em>.
<p> The characters are not null terminated.
<p> <p>See also <a href="#codecForContent">codecForContent</a>().

<h3 class=fn>int <a name="heuristicNameMatch"></a>QTextCodec::heuristicNameMatch ( const&nbsp;char&nbsp;*&nbsp;hint ) const<tt> [virtual]</tt>
</h3>
Returns a value indicating how likely it is that this decoder is
appropriate for decoding some format that has the given name. The name is
compared with the <em>hint</em>.
<p> A good match returns a positive number around
the length of the string.  A bad match is negative.
<p> The default implementation calls <a href="#simpleHeuristicNameMatch">simpleHeuristicNameMatch</a>()
with the name of the codec.

<h3 class=fn><a href="qtextcodec.html">QTextCodec</a>&nbsp;* <a name="loadCharmap"></a>QTextCodec::loadCharmap ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;iod )<tt> [static]</tt>
</h3>
Reads a POSIX2 charmap definition from <em>iod</em>.
The parser recognizes the following lines:
<p> <font name="sans">
&nbsp;&nbsp;&lt;code_set_name&gt; <i>name</i></br>
&nbsp;&nbsp;&lt;escape_char&gt; <i>character</i></br>
&nbsp;&nbsp;% alias <i>alias</i></br>
&nbsp;&nbsp;CHARMAP</br>
&nbsp;&nbsp;&lt;<i>token</i>&gt; /x<i>hexbyte</i> &lt;U<i>unicode</i>&gt; ...</br>
&nbsp;&nbsp;&lt;<i>token</i>&gt; /d<i>decbyte</i> &lt;U<i>unicode</i>&gt; ...</br>
&nbsp;&nbsp;&lt;<i>token</i>&gt; /<i>octbyte</i> &lt;U<i>unicode</i>&gt; ...</br>
&nbsp;&nbsp;&lt;<i>token</i>&gt; /<i>any</i>/<i>any</i>... &lt;U<i>unicode</i>&gt; ...</br>
&nbsp;&nbsp;END CHARMAP</br>
</font>
<p> The resulting QTextCodec is returned (and also added to the
global list of codecs).  The <a href="#name">name</a>() of the result is taken
from the code_set_name.
<p> Note that a codec constructed in this way uses much more memory
and is slower than a hand-written QTextCodec subclass, since
tables in code are in memory shared by all applications simultaneously
using Qt.
<p> <p>See also <a href="#loadCharmapFile">loadCharmapFile</a>().

<p>Example: <a href="qwerty-example.html#x656">qwerty/qwerty.cpp</a>.
<h3 class=fn><a href="qtextcodec.html">QTextCodec</a>&nbsp;* <a name="loadCharmapFile"></a>QTextCodec::loadCharmapFile ( <a href="qstring.html">QString</a>&nbsp;filename )<tt> [static]</tt>
</h3>
A convenience function for <a href="#loadCharmap">loadCharmap</a>() that loads the charmap
definition from the file <em>filename</em>.

<h3 class=fn>const char * <a name="locale"></a>QTextCodec::locale ()<tt> [static]</tt>
</h3>
Returns a string representing the current language.

<p>Example: <a href="i18n-example.html#x1380">i18n/main.cpp</a>.
<h3 class=fn><a href="qtextdecoder.html">QTextDecoder</a>&nbsp;* <a name="makeDecoder"></a>QTextCodec::makeDecoder () const<tt> [virtual]</tt>
</h3>
Creates a <a href="qtextdecoder.html">QTextDecoder</a> which stores enough state to decode chunks
of char* data to create chunks of Unicode data.  The default implementation
creates a stateless decoder, which is sufficient for only the simplest
encodings where each byte corresponds to exactly one Unicode character.
<p> The caller is responsible for deleting the returned object.

<h3 class=fn><a href="qtextencoder.html">QTextEncoder</a>&nbsp;* <a name="makeEncoder"></a>QTextCodec::makeEncoder () const<tt> [virtual]</tt>
</h3>
Creates a <a href="qtextencoder.html">QTextEncoder</a> which stores enough state to encode chunks
of Unicode data as char* data.  The default implementation
creates a stateless encoder, which is sufficient for only the simplest
encodings where each Unicode character corresponds to exactly one character.
<p> The caller is responsible for deleting the returned object.

<h3 class=fn>int <a name="mibEnum"></a>QTextCodec::mibEnum () const<tt> [pure virtual]</tt>
</h3>

<p> Subclasses of QTextCodec must reimplement this function.  It returns the
MIBenum (see
<a href="ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets">the IANA character-sets encoding file</a> for more information).
It is important that each QTextCodec subclass return the correct unique
value for this function.

<p>Reimplemented in <a href="qeucjpcodec.html#mibEnum">QEucJpCodec</a>.
<h3 class=fn>const char * <a name="mimeName"></a>QTextCodec::mimeName () const<tt> [virtual]</tt>
</h3>
Returns the preferred mime name of the encoding as defined in the
<a href="ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets">IANA character-sets encoding file</a>.

<p>Reimplemented in <a href="qeucjpcodec.html#mimeName">QEucJpCodec</a>, <a href="qeuckrcodec.html#mimeName">QEucKrCodec</a>, <a href="qgbkcodec.html#mimeName">QGbkCodec</a>, <a href="qjiscodec.html#mimeName">QJisCodec</a>, <a href="qhebrewcodec.html#mimeName">QHebrewCodec</a> and <a href="qsjiscodec.html#mimeName">QSjisCodec</a>.
<h3 class=fn>const char * <a name="name"></a>QTextCodec::name () const<tt> [pure virtual]</tt>
</h3>

Subclasses of QTextCodec must reimplement this function.  It returns
the name of the encoding supported by the subclass.  When choosing
a name for an encoding, consider these points:
<ul>
<li> On X11, <a href="#heuristicNameMatch">heuristicNameMatch</a>( const char * hint )
is used to test if a the QTextCodec
can convert between Unicode and the encoding of a font
with encoding <em>hint</em>, such as "iso8859-1" for Latin-1 fonts,
"koi8-r" for Russian KOI8 fonts.
The default algorithm of heuristicNameMatch() uses <a href="#name">name</a>().
<li> Some applications may use this function to present
encodings to the end user.
</ul>

<p>Example: <a href="qwerty-example.html#x657">qwerty/qwerty.cpp</a>.
<h3 class=fn>void <a name="setCodecForLocale"></a>QTextCodec::setCodecForLocale ( <a href="qtextcodec.html">QTextCodec</a>&nbsp;*&nbsp;c )<tt> [static]</tt>
</h3>
Set the codec to <em>c</em>; this will be returned by codecForLocale.
This might be needed for some applications, that want to use their
own mechanism for setting the locale.
<p> <p>See also <a href="#codecForLocale">codecForLocale</a>().

<h3 class=fn>int <a name="simpleHeuristicNameMatch"></a>QTextCodec::simpleHeuristicNameMatch ( const&nbsp;char&nbsp;*&nbsp;name, const&nbsp;char&nbsp;*&nbsp;hint )<tt> [static protected]</tt>
</h3>
A simple utility function for <a href="#heuristicNameMatch">heuristicNameMatch</a>(): it
does some very minor character-skipping
so that almost-exact matches score high.
<em>name</em> is the text we're matching and <em>hint</em> is used for the
comparison.

<h3 class=fn><a href="qstring.html">QString</a> <a name="toUnicode"></a>QTextCodec::toUnicode ( const&nbsp;char&nbsp;*&nbsp;chars, int&nbsp;len ) const<tt> [virtual]</tt>
</h3>
Subclasses of QTextCodec must reimplement this function or
<a href="#makeDecoder">makeDecoder</a>().  It converts the first <em>len</em> characters of <em>chars</em>
to Unicode.
<p> The default implementation makes a decoder with makeDecoder() and
converts the input with that.  Note that the default makeDecoder()
implementation makes a decoder that simply calls
this function, hence subclasses <em>must</em> reimplement one function or
the other to avoid infinite recursion.

<h3 class=fn><a href="qstring.html">QString</a> <a name="toUnicode-2"></a>QTextCodec::toUnicode ( const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;a, int&nbsp;len ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <em>a</em> contains the source characters; <em>len</em> contains the number of
characters in <em>a</em> to use.

<h3 class=fn><a href="qstring.html">QString</a> <a name="toUnicode-3"></a>QTextCodec::toUnicode ( const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;a ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <em>a</em> contains the source characters.

<h3 class=fn><a href="qstring.html">QString</a> <a name="toUnicode-4"></a>QTextCodec::toUnicode ( const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;a, int&nbsp;len ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <em>a</em> contains the source characters; <em>len</em> contains the number of
characters in <em>a</em> to use.

<h3 class=fn><a href="qstring.html">QString</a> <a name="toUnicode-5"></a>QTextCodec::toUnicode ( const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;a ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <em>a</em> contains the source characters.

<h3 class=fn><a href="qstring.html">QString</a> <a name="toUnicode-6"></a>QTextCodec::toUnicode ( const&nbsp;char&nbsp;*&nbsp;chars ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <em>chars</em> contains the source characters.

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2001
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>