qtextcodec.html
来自「QT 下载资料仅供参考」· HTML 代码 · 共 536 行 · 第 1/2 页
HTML
536 行
<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 responsibilityof 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 deletecodecs yourself: once created they become Qt's responsibility.<h3 class=fn>bool <a name="canEncode"></a>QTextCodec::canEncode ( <a href="qchar.html">QChar</a> ch ) const<tt> [virtual]</tt></h3>Returns TRUE if the unicode character <em>ch</em> can be fully encodedwith this codec; otherwise returns FALSE. The defaultimplementation tests if the result of <a href="#toUnicode">toUnicode</a>(fromUnicode(ch)) isthe original <em>ch</em>. Subclasses may be able to improve theefficiency.<h3 class=fn>bool <a name="canEncode-2"></a>QTextCodec::canEncode ( const <a href="qstring.html">QString</a> & 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> * <a name="codecForContent"></a>QTextCodec::codecForContent ( const char * chars, int len )<tt> [static]</tt></h3>Searches all installed QTextCodec objects, returning the onewhich most recognizes the given content. May return 0.<p> Note that this is often a poor choice, since characterencodings 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 thenumber of characters in the string to use.<p> <p>See also <a href="#heuristicContentMatch">heuristicContentMatch</a>().<p>Example: <a href="qwerty-example.html#x389">qwerty/qwerty.cpp</a>.<h3 class=fn><a href="qtextcodec.html">QTextCodec</a> * <a name="codecForIndex"></a>QTextCodec::codecForIndex ( int i )<tt> [static]</tt></h3>Returns the QTextCodec <em>i</em> positions from the most recentlyinserted 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#x390">qwerty/qwerty.cpp</a>.<h3 class=fn><a href="qtextcodec.html">QTextCodec</a> * <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#x391">qwerty/qwerty.cpp</a>.<h3 class=fn><a href="qtextcodec.html">QTextCodec</a> * <a name="codecForMib"></a>QTextCodec::codecForMib ( int 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> * <a name="codecForName"></a>QTextCodec::codecForName ( const char * name, int accuracy = 0 )<tt> [static]</tt></h3>Searches all installed QTextCodec objects and returns the onewhich 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>, orif <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 anyQTextCodec objects that may be lying around. Since various otherclasses hold pointers to QTextCodec objects, it is not safe to callthis function earlier.<p> If you are using the utility classes (like <a href="qstring.html">QString</a>) but not usingQApplication, calling this function at the very end of yourapplication can be helpful to chase down memory leaks, asQTextCodec objects will not show up.<h3 class=fn><a href="qcstring.html">QCString</a> <a name="fromUnicode"></a>QTextCodec::fromUnicode ( const <a href="qstring.html">QString</a> & uc, int & 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> Converts <em>lenInOut</em> characters (not bytes) from <em>uc</em>, producinga <a href="qcstring.html">QCString</a>. <em>lenInOut</em> will be set to the<a href="qcstring.html#length">length</a> of the result (in bytes).<p> The default implementation makes an encoder with makeEncoder() andconverts the input with that. Note that the default makeEncoder()implementation makes an encoder that simply callsthis function, hence subclasses <em>must</em> reimplement one function orthe 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 <a href="qstring.html">QString</a> & 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 char * chars, int len ) const<tt> [pure virtual]</tt></h3><p> Subclasses of QTextCodec must reimplement this function. It examinesthe first <em>len</em> bytes of <em>chars</em> and returns a value indicating howlikely it is that the string is a prefix of text encoded in theencoding of the subclass. A negative return value indicates thatthe text is detectably not in the encoding (e.g. it containscharacters undefined in the encoding). A return value of 0 indicatesthat the text should be decoded with this codec rather than asASCII, but there is no particular evidence. The value should rangeup 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 char * hint ) const<tt> [virtual]</tt></h3>Returns a value indicating how likely it is that this decoder isappropriate for decoding some format that has the given name. The name iscompared with the <em>hint</em>.<p> A good match returns a positive number aroundthe 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> * <a name="loadCharmap"></a>QTextCodec::loadCharmap ( <a href="qiodevice.html">QIODevice</a> * iod )<tt> [static]</tt></h3>Reads a POSIX2 charmap definition from <em>iod</em>.The parser recognizes the following lines:<p> <font name="sans"> <code_set_name> <i>name</i></br> <escape_char> <i>character</i></br> % alias <i>alias</i></br> CHARMAP</br> <<i>token</i>> /x<i>hexbyte</i> <U<i>unicode</i>> ...</br> <<i>token</i>> /d<i>decbyte</i> <U<i>unicode</i>> ...</br> <<i>token</i>> /<i>octbyte</i> <U<i>unicode</i>> ...</br> <<i>token</i>> /<i>any</i>/<i>any</i>... <U<i>unicode</i>> ...</br> END CHARMAP</br></font><p> The resulting QTextCodec is returned (and also added to theglobal list of codecs). The <a href="#name">name</a>() of the result is takenfrom the code_set_name.<p> Note that a codec constructed in this way uses much more memoryand is slower than a hand-written QTextCodec subclass, sincetables in code are in memory shared by all applications simultaneouslyusing Qt.<p> <p>See also <a href="#loadCharmapFile">loadCharmapFile</a>().<p>Example: <a href="qwerty-example.html#x392">qwerty/qwerty.cpp</a>.<h3 class=fn><a href="qtextcodec.html">QTextCodec</a> * <a name="loadCharmapFile"></a>QTextCodec::loadCharmapFile ( <a href="qstring.html">QString</a> filename )<tt> [static]</tt></h3>A convenience function for <a href="#loadCharmap">loadCharmap</a>() that loads the charmapdefinition 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#x1935">i18n/main.cpp</a>.<h3 class=fn><a href="qtextdecoder.html">QTextDecoder</a> * <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 chunksof char* data to create chunks of Unicode data. The default implementationcreates a stateless decoder, which is sufficient for only the simplestencodings 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> * <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 chunksof Unicode data as char* data. The default implementationcreates a stateless encoder, which is sufficient for only the simplestencodings 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 theMIBenum (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 returns the correctunique 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><p> Subclasses of QTextCodec must reimplement this function. It returnsthe name of the encoding supported by the subclass. When choosinga 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 QTextCodeccan convert between Unicode and the encoding of a fontwith 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 presentencodings to the end user.</ul><p>Example: <a href="qwerty-example.html#x393">qwerty/qwerty.cpp</a>.<h3 class=fn>void <a name="setCodecForLocale"></a>QTextCodec::setCodecForLocale ( <a href="qtextcodec.html">QTextCodec</a> * c )<tt> [static]</tt></h3>Set the codec to <em>c</em>; this will be returned by <a href="#codecForLocale">codecForLocale</a>().This might be needed for some applications that want to use theirown 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 char * name, const char * hint )<tt> [static protected]</tt></h3>A simple utility function for <a href="#heuristicNameMatch">heuristicNameMatch</a>(): itdoes some very minor character-skippingso that almost-exact matches score high.<em>name</em> is the text we're matching and <em>hint</em> is used for thecomparison.<h3 class=fn><a href="qstring.html">QString</a> <a name="toUnicode"></a>QTextCodec::toUnicode ( const char * chars, int 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() andconverts the input with that. Note that the default makeDecoder()implementation makes a decoder that simply callsthis function, hence subclasses <em>must</em> reimplement one function orthe other to avoid infinite recursion.<h3 class=fn><a href="qstring.html">QString</a> <a name="toUnicode-2"></a>QTextCodec::toUnicode ( const <a href="qbytearray.html">QByteArray</a> & a, int 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 ofcharacters in <em>a</em> to use.<h3 class=fn><a href="qstring.html">QString</a> <a name="toUnicode-3"></a>QTextCodec::toUnicode ( const <a href="qbytearray.html">QByteArray</a> & 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 <a href="qcstring.html">QCString</a> & a, int 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 ofcharacters in <em>a</em> to use.<h3 class=fn><a href="qstring.html">QString</a> <a name="toUnicode-5"></a>QTextCodec::toUnicode ( const <a href="qcstring.html">QCString</a> & 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 char * 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 © 1995-2002<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 © 2002 <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.5</div></table></div></address></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?