📄 qtextcodec.3qt
字号:
.IP "\fCint\fR heuristicNameMatch(const char* hint) const" 1cTest if a possibly non-standard name is referring to the codec..PP.SH MEMBER FUNCTION DOCUMENTATION.SH "QTextCodec::QTextCodec () \fC[protected]\fR"Constructs a QTextCodec, making it of highest precedence. The QTextCodec should always be constructed on the heap (with new), and once constructed it becomes the responsibility of Qt to delete it (which is done at QApplication destruction)..SH "QTextCodec::~QTextCodec () \fC[virtual]\fR"Destructs the QTextCodec. Note that you should not delete codecs yourself - once created they become the responsibility of Qt to delete..SH "bool QTextCodec::canEncode ( QChar ch ) const \fC[virtual]\fR"Returns TRUE if the unicode character \fIch\fR can be fully encoded with this codec. The default implementation tests if the result of toUnicode(fromUnicode(ch)) is the original \fIch.\fR Subclasses may be able to improve the efficiency..SH "bool QTextCodec::canEncode ( const QString & s ) const \fC[virtual]\fR"Returns TRUE if the unicode string \fIs\fR can be fully encoded with this codec. The default implementation tests if the result of toUnicode(fromUnicode(s)) is the original \fIs.\fR Subclasses may be able to improve the efficiency..SH "QTextCodec* QTextCodec::codecForContent ( const char * chars, int len ) \fC[static]\fR"Searches all installed QTextCodec objects, returning the one which most recognizes the given content. May return 0..PPNote 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..PPSee also heuristicContentMatch()..SH "QTextCodec* QTextCodec::codecForIndex ( int i ) \fC[static]\fR"Returns the QTextCodec \fIi\fR places from the more recently inserted, or NULL if there is no such QTextCodec. Thus, codecForIndex(0) returns the most recently created QTextCodec..SH "QTextCodec* QTextCodec::codecForLocale () \fC[static]\fR"Returns a pointer to the codec most suitable for this locale..SH "QTextCodec* QTextCodec::codecForMib ( int mib ) \fC[static]\fR"Returns the QTextCodec which matches the MIBenum \fImib.\fR.SH "QTextCodec* QTextCodec::codecForName ( const char * hint, int accuracy=0 ) \fC[static]\fR"Searches all installed QTextCodec objects, returning the one which best matches given name. Returns NULL if no codec has a match closeness above \fIaccuracy.\fR.PPSee also heuristicNameMatch()..SH "void QTextCodec::deleteAllCodecs () \fC[static]\fR"Deletes all the created codecs..PP\fBWarning:\fR Do not call this function..PPQApplication 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..PPIf you are using the utility classes (like QString) but not using QApplication, calling this function at the very end of your application can be helpful to chasing down memory leaks, as QTextCodec objects will not show up..SH "QCString QTextCodec::fromUnicode ( const QString & uc, int & lenInOut ) const \fC[virtual]\fR"Subclasses of QTextCodec must reimplement either this function or makeEncoder(). It converts the first \fIlenInOut\fR characters of \fIuc\fR from Unicode to the encoding of the subclass. If \fIlenInOut\fR is negative or too large, the length of \fIuc\fR is used instead..PPThe value returned is the property of the caller, which is responsible for deleting it with "delete []". The length of the resulting Unicode character sequence is returned in \fIlenInOut.\fR.PPThe 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 \fImust\fR reimplement one function or the other to avoid infinite recursion..PPReimplemented in QJisCodec, QEucJpCodec, QSjisCodec, QEucKrCodec, QGbkCodec and QTsciiCodec..SH "QCString QTextCodec::fromUnicode ( const QString & uc ) const"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "int QTextCodec::heuristicContentMatch ( const char * chars, int len ) const \fC[virtual]\fR"Subclasses of QTextCodec must reimplement this function. It examines the first \fIlen\fR bytes of \fIchars\fR and returns a value indicating how likely it is that the string is a prefix of text encoded in the encoding of the subclass. Any negative return value indicates that the text is detectably not in the encoding (eg. it contains undefined characters). 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 \fIlen.\fR Thus, most decoders will return -1, 0, or -\fIlen.\fR.PPThe characters are not null terminated..PPSee also codecForContent()..PPReimplemented in QEucJpCodec, QEucKrCodec, QSjisCodec, QJisCodec, QTsciiCodec and QGbkCodec..SH "int QTextCodec::heuristicNameMatch ( const char * hint ) const \fC[virtual]\fR"Returns a value indicating how likely this decoder is for decoding some format that has the given name..PPA good match returns a positive number around the length of the string. A bad match is negative..PPThe default implementation calls simpleHeuristicNameMatch() with the name of the codec..PPReimplemented in QEucJpCodec, QGbkCodec, QSjisCodec, QEucKrCodec, QJisCodec and QTsciiCodec..SH "QTextCodec* QTextCodec::loadCharmap ( QIODevice * iod ) \fC[static]\fR"Reads a POSIX2 charmap definition from \fIiod.\fR The parser recognizes the following lines:.PP.nf.br <code_set_name> \fIname\fR.br <escape_char> \fIcharacter\fR.br % alias \fIalias\fR.br CHARMAP.br <\fItoken\fR> /x\fIhexbyte\fR <U\fIunicode\fR> ....br <\fItoken\fR> /d\fIdecbyte\fR <U\fIunicode\fR> ....br <\fItoken\fR> /\fIoctbyte\fR <U\fIunicode\fR> ....br <\fItoken\fR> /\fIany\fR/\fIany\fR... <U\fIunicode\fR> ....br END CHARMAP.fi.PPThe resulting QTextCodec is returned (and also added to the global list of codecs). The name() of the result is taken from the code_set_name..PPNote 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..PPSee also loadCharmapFile()..SH "QTextCodec* QTextCodec::loadCharmapFile ( QString filename ) \fC[static]\fR"A convenience function for loadCharmap()..SH "const char* QTextCodec::locale () \fC[static]\fR"Returns a string representing the current language..SH "QTextDecoder* QTextCodec::makeDecoder () const \fC[virtual]\fR"Creates a QTextDecoder 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..PPThe caller is responsible for deleting the returned object..PPReimplemented in QEucKrCodec, QJisCodec, QSjisCodec, QGbkCodec and QEucJpCodec..SH "QTextEncoder* QTextCodec::makeEncoder () const \fC[virtual]\fR"Creates a QTextEncoder 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 char..PPThe caller is responsible for deleting the returned object..SH "int QTextCodec::mibEnum () const \fC[virtual]\fR"Subclasses of QTextCodec must reimplement this function. It returns the MIBenum (see the IANA character-sets encoding file for more information). It is important that each QTextCodec subclass return the correct unique value for this function..SH "const char* QTextCodec::name () const \fC[virtual]\fR"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:.TPOn X11, heuristicNameMatch( const char * hint ) is used to test if a the QTextCodec can convert between Unicode and the encoding of a font with encoding \fIhint,\fR such as "iso8859-1" for Latin-1 fonts," koi8-r" for Russian KOI8 fonts. The default algorithm of heuristicNameMatch() uses name()..TPSome applications may use this function to present encodings to the end user..PPReimplemented in QJisCodec, QSjisCodec, QEucJpCodec, QTsciiCodec, QEucKrCodec and QGbkCodec..SH "int QTextCodec::simpleHeuristicNameMatch ( const char * name, const char * hint ) \fC[static protected]\fR"A simple utility function for heuristicNameMatch() - it does some very minor character-skipping so that almost-exact matches score high..SH "QString QTextCodec::toUnicode ( const char * chars, int len ) const \fC[virtual]\fR"Subclasses of QTextCodec must reimplement this function or makeDecoder(). It converts the first \fIlen\fR characters of \fIchars\fR to Unicode..PPThe 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 \fImust\fR reimplement one function or the other to avoid infinite recursion..PPReimplemented in QTsciiCodec, QEucKrCodec, QEucJpCodec, QGbkCodec, QJisCodec and QSjisCodec..SH "QString QTextCodec::toUnicode ( const QByteArray & a ) const"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QString QTextCodec::toUnicode ( const QByteArray & a, int len ) const"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QString QTextCodec::toUnicode ( const char * chars ) const"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "SEE ALSO".BR http://doc.trolltech.com/qtextcodec.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qtextcodec.3qt) and the Qtversion (2.3.10).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -