Eneboo - Documentación para desarrolladores
|
The QTextCodec class provides conversion between text encodings. 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. Más...
#include <qtextcodec.h>
Métodos públicos | |
virtual | ~QTextCodec () |
virtual const char * | name () const =0 |
virtual const char * | mimeName () const |
virtual int | mibEnum () const =0 |
virtual QTextDecoder * | makeDecoder () const |
virtual QTextEncoder * | makeEncoder () const |
virtual QString | toUnicode (const char *chars, int len) const |
virtual QCString | fromUnicode (const QString &uc, int &lenInOut) const |
QCString | fromUnicode (const QString &uc) const |
QString | toUnicode (const QByteArray &, int len) const |
QString | toUnicode (const QByteArray &) const |
QString | toUnicode (const QCString &, int len) const |
QString | toUnicode (const QCString &) const |
QString | toUnicode (const char *chars) const |
virtual bool | canEncode (QChar) const |
virtual bool | canEncode (const QString &) const |
virtual int | heuristicContentMatch (const char *chars, int len) const =0 |
virtual int | heuristicNameMatch (const char *hint) const |
virtual QByteArray | fromUnicode (const QString &uc, int from, int len) const |
virtual unsigned short | characterFromUnicode (const QString &str, int pos) const |
virtual | ~QTextCodec () |
virtual const char * | name () const =0 |
virtual const char * | mimeName () const |
virtual int | mibEnum () const =0 |
virtual QTextDecoder * | makeDecoder () const |
virtual QTextEncoder * | makeEncoder () const |
virtual QString | toUnicode (const char *chars, int len) const |
virtual QCString | fromUnicode (const QString &uc, int &lenInOut) const |
QCString | fromUnicode (const QString &uc) const |
QString | toUnicode (const QByteArray &, int len) const |
QString | toUnicode (const QByteArray &) const |
QString | toUnicode (const QCString &, int len) const |
QString | toUnicode (const QCString &) const |
QString | toUnicode (const char *chars) const |
virtual bool | canEncode (QChar) const |
virtual bool | canEncode (const QString &) const |
virtual int | heuristicContentMatch (const char *chars, int len) const =0 |
virtual int | heuristicNameMatch (const char *hint) const |
virtual QByteArray | fromUnicode (const QString &uc, int from, int len) const |
virtual unsigned short | characterFromUnicode (const QString &str, int pos) const |
Métodos públicos estáticos | |
static QTextCodec * | loadCharmap (QIODevice *) |
static QTextCodec * | loadCharmapFile (QString filename) |
static QTextCodec * | codecForMib (int mib) |
static QTextCodec * | codecForName (const char *hint, int accuracy=0) |
static QTextCodec * | codecForContent (const char *chars, int len) |
static QTextCodec * | codecForIndex (int i) |
static QTextCodec * | codecForLocale () |
static void | setCodecForLocale (QTextCodec *c) |
static QTextCodec * | codecForTr () |
static void | setCodecForTr (QTextCodec *c) |
static QTextCodec * | codecForCStrings () |
static void | setCodecForCStrings (QTextCodec *c) |
static void | deleteAllCodecs () |
static const char * | locale () |
static QTextCodec * | loadCharmap (QIODevice *) |
static QTextCodec * | loadCharmapFile (QString filename) |
static QTextCodec * | codecForMib (int mib) |
static QTextCodec * | codecForName (const char *hint, int accuracy=0) |
static QTextCodec * | codecForContent (const char *chars, int len) |
static QTextCodec * | codecForIndex (int i) |
static QTextCodec * | codecForLocale () |
static void | setCodecForLocale (QTextCodec *c) |
static QTextCodec * | codecForTr () |
static void | setCodecForTr (QTextCodec *c) |
static QTextCodec * | codecForCStrings () |
static void | setCodecForCStrings (QTextCodec *c) |
static void | deleteAllCodecs () |
static const char * | locale () |
Métodos protegidos | |
QTextCodec () | |
QTextCodec () | |
Métodos protegidos estáticos | |
static int | simpleHeuristicNameMatch (const char *name, const char *hint) |
static int | simpleHeuristicNameMatch (const char *name, const char *hint) |
Amigas | |
class | QFont |
class | QFontEngineXLFD |
The QTextCodec class provides conversion between text encodings.
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.
Qt provides a set of QTextCodec classes to help with converting non-Unicode formats to and from Unicode. You can also create your own codec classes (see later).
The supported encodings are: Latin1 Big5 -- Chinese Big5-HKSCS -- Chinese eucJP -- Japanese eucKR -- Korean GB2312 -- Chinese GBK -- Chinese GB18030 -- Chinese JIS7 -- Japanese Shift-JIS -- Japanese TSCII -- Tamil utf8 -- Unicode, 8-bit utf16 -- Unicode KOI8-R -- Russian KOI8-U -- Ukrainian ISO8859-1 -- Western ISO8859-2 -- Central European ISO8859-3 -- Central European ISO8859-4 -- Baltic ISO8859-5 -- Cyrillic ISO8859-6 -- Arabic ISO8859-7 -- Greek ISO8859-8 -- Hebrew, visually ordered ISO8859-8-i -- Hebrew, logically ordered ISO8859-9 -- Turkish ISO8859-10 ISO8859-13 ISO8859-14 ISO8859-15 -- Western IBM 850 IBM 866 CP874 CP1250 -- Central European CP1251 -- Cyrillic CP1252 -- Western CP1253 -- Greek CP1254 -- Turkish CP1255 -- Hebrew CP1256 -- Arabic CP1257 -- Baltic CP1258 Apple Roman TIS-620 -- Thai
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:
QCString locallyEncoded = "..."; // text to convert QTextCodec *codec = QTextCodec::codecForName("KOI8-R"); // get the codec for KOI8-R QString unicodeString = codec->toUnicode( locallyEncoded );
After this, {unicodeString} holds the text converted to Unicode. Converting a string from Unicode to the local encoding is just as easy:
QString unicodeString = "..."; // any Unicode text QTextCodec *codec = QTextCodec::codecForName("KOI8-R"); // get the codec for KOI8-R QCString locallyEncoded = codec->fromUnicode( unicodeString );
Some care must be taken when trying to convert the data in chunks, for example, when receiving it over a network. In such cases it is possible that a multi-byte character will be split over two chunks. At best this might result in the loss of a character and at worst cause the entire conversion to fail.
The approach to use in these situations is to create a QTextDecoder object for the codec and use this QTextDecoder for the whole decoding process, as shown below:
QTextCodec *codec = QTextCodec::codecForName( "Shift-JIS" ); QTextDecoder *decoder = codec->makeDecoder(); QString unicodeString; while( receiving_data ) { QByteArray chunk = new_data; unicodeString += decoder->toUnicode( chunk.data(), chunk.length() ); }
The QTextDecoder object maintains state between chunks and therefore works correctly even if a multi-byte character is split between chunks.
subclassing
QTextCodec::~QTextCodec | ( | ) | [virtual] |
Destroys the QTextCodec. Note that you should not delete codecs yourself: once created they become Qt's responsibility.
QTextCodec::QTextCodec | ( | ) | [protected] |
Constructs a QTextCodec, and gives it the highest precedence. The QTextCodec should always be constructed on the heap (i.e. with new
). Qt takes ownership and will delete it when the application terminates.
virtual QTextCodec::~QTextCodec | ( | ) | [virtual] |
QTextCodec::QTextCodec | ( | ) | [protected] |
Returns TRUE if the Unicode character ch can be fully encoded with this codec; otherwise returns FALSE. The default implementation tests if the result of toUnicode(fromUnicode(ch)) is the original ch. Subclasses may be able to improve the efficiency.
Reimplementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec y QSimpleTextCodec.
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. s contains the string being tested for encode-ability.
Reimplementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec y QSimpleTextCodec.
Reimplementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QSimpleTextCodec, QLatin1Codec y QLatin15Codec.
virtual unsigned short QTextCodec::characterFromUnicode | ( | const QString & | str, |
int | pos | ||
) | const [virtual] |
Reimplementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QSimpleTextCodec, QLatin1Codec y QLatin15Codec.
static QTextCodec* QTextCodec::codecForContent | ( | const char * | chars, |
int | len | ||
) | [static] |
QTextCodec * QTextCodec::codecForContent | ( | const char * | chars, |
int | len | ||
) | [static] |
Searches all installed QTextCodec objects, returning the one which most recognizes the given content. May return 0.
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.
chars contains the string to check, and len contains the number of characters in the string to use.
QTextCodec * QTextCodec::codecForCStrings | ( | ) | [inline, static] |
Returns the codec used by QString to convert to and from const char* and QCStrings. If this function returns 0 (the default), QString assumes Latin-1.
static QTextCodec* QTextCodec::codecForCStrings | ( | ) | [static] |
static QTextCodec* QTextCodec::codecForIndex | ( | int | i | ) | [static] |
QTextCodec * QTextCodec::codecForIndex | ( | int | i | ) | [static] |
Returns the QTextCodec i positions from the most recently inserted codec, or 0 if there is no such QTextCodec. Thus, codecForIndex(0) returns the most recently created QTextCodec.
static QTextCodec* QTextCodec::codecForLocale | ( | ) | [static] |
QTextCodec * QTextCodec::codecForLocale | ( | ) | [static] |
Returns a pointer to the codec most suitable for this locale.
static QTextCodec* QTextCodec::codecForMib | ( | int | mib | ) | [static] |
QTextCodec * QTextCodec::codecForMib | ( | int | mib | ) | [static] |
Returns the QTextCodec which matches the MIBenum mib.
static QTextCodec* QTextCodec::codecForName | ( | const char * | hint, |
int | accuracy = 0 |
||
) | [static] |
QTextCodec * QTextCodec::codecForName | ( | const char * | name, |
int | accuracy = 0 |
||
) | [static] |
Searches all installed QTextCodec objects and returns the one which best matches name; the match is case-insensitive. Returns 0 if no codec's heuristicNameMatch() reports a match better than accuracy, or if name is a null string.
QTextCodec * QTextCodec::codecForTr | ( | ) | [inline, static] |
Returns the codec used by QObject::tr() on its argument. If this function returns 0 (the default), tr() assumes Latin-1.
static QTextCodec* QTextCodec::codecForTr | ( | ) | [static] |
static void QTextCodec::deleteAllCodecs | ( | ) | [static] |
void QTextCodec::deleteAllCodecs | ( | ) | [static] |
Deletes all the created codecs.
QApplication calls this function 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.
If you are using the utility classes (like QString) but not using QApplication, calling this function at the very end of your application may be helpful for chasing down memory leaks by eliminating any QTextCodec objects.
QByteArray QTextCodec::fromUnicode | ( | const QString & | str, |
int | pos, | ||
int | len | ||
) | const [virtual] |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.
QTextCodec subclasses must reimplement either this function or makeEncoder(). It converts the first lenInOut characters of uc from Unicode to the encoding of the subclass. If lenInOut is negative or too large, the length of uc is used instead.
Converts lenInOut characters (not bytes) from uc, producing a QCString. lenInOut will be set to the length of the result (in bytes).
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 must reimplement one function or the other to avoid infinite recursion.
Reimplementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QHebrewCodec, QSjisCodec, QTsciiCodec, QUtf8Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec, QLatin1Codec, QLatin15Codec, QTsciiCodec y QUtf8Codec.
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. uc is the unicode source string.
Reimplementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QHebrewCodec, QSjisCodec, QTsciiCodec, QUtf8Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec, QLatin1Codec, QLatin15Codec, QTsciiCodec y QUtf8Codec.
virtual QByteArray QTextCodec::fromUnicode | ( | const QString & | uc, |
int | from, | ||
int | len | ||
) | const [virtual] |
Implementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QHebrewCodec, QSjisCodec, QTsciiCodec, QUtf8Codec, QUtf16Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec, QLatin1Codec, QTsciiCodec, QUtf8Codec y QUtf16Codec.
QTextCodec subclasses must reimplement this function. It examines the first len bytes of chars 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 len. Thus, most decoders will return -1, 0, or -len.
The characters are not null terminated.
Implementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QHebrewCodec, QSjisCodec, QTsciiCodec, QUtf8Codec, QUtf16Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec, QLatin1Codec, QTsciiCodec, QUtf8Codec y QUtf16Codec.
virtual int QTextCodec::heuristicNameMatch | ( | const char * | hint | ) | const [virtual] |
Reimplementado en QFontJis0201Codec, QFontJis0208Codec, QFontGbkCodec, QFontBig5Codec, QFontBig5hkscsCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QSjisCodec, QTsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0201Codec, QFontJis0208Codec, QFontGbkCodec, QFontBig5Codec, QFontBig5hkscsCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec y QTsciiCodec.
int QTextCodec::heuristicNameMatch | ( | const char * | hint | ) | const [virtual] |
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 hint.
A good match returns a positive number around the length of the string. A bad match is negative.
The default implementation calls simpleHeuristicNameMatch() with the name of the codec.
Reimplementado en QFontJis0201Codec, QFontJis0208Codec, QFontGbkCodec, QFontBig5Codec, QFontBig5hkscsCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QSjisCodec, QTsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0201Codec, QFontJis0208Codec, QFontGbkCodec, QFontBig5Codec, QFontBig5hkscsCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec y QTsciiCodec.
static QTextCodec* QTextCodec::loadCharmap | ( | QIODevice * | ) | [static] |
QTextCodec * QTextCodec::loadCharmap | ( | QIODevice * | iod | ) | [static] |
Reads a POSIX2 charmap definition from iod. The parser recognizes the following lines:
<font name="sans"> <code_set_name> name <escape_char> character % alias alias CHARMAP <token> /xhexbyte <Uunicode> ... <token> /ddecbyte <Uunicode> ... <token> /octbyte <Uunicode> ... <token> /any/any... <Uunicode> ... END CHARMAP </font>
The 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.
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 kept in memory shared by all Qt applications.
QTextCodec * QTextCodec::loadCharmapFile | ( | QString | filename | ) | [static] |
A convenience function for loadCharmap() that loads the charmap definition from the file filename.
static QTextCodec* QTextCodec::loadCharmapFile | ( | QString | filename | ) | [static] |
static const char* QTextCodec::locale | ( | ) | [static] |
const char * QTextCodec::locale | ( | ) | [static] |
Returns a string representing the current language and sublanguage, e.g. "pt" for Portuguese, or "pt_br" for Portuguese/Brazil.
QTextDecoder * QTextCodec::makeDecoder | ( | ) | const [virtual] |
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 only sufficient for the simplest encodings where each byte corresponds to exactly one Unicode character.
The caller is responsible for deleting the returned object.
Reimplementado en QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QSjisCodec, QUtf8Codec, QUtf16Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QSjisCodec, QTextCodecFromIOD, QUtf8Codec y QUtf16Codec.
virtual QTextDecoder* QTextCodec::makeDecoder | ( | ) | const [virtual] |
Reimplementado en QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QSjisCodec, QUtf8Codec, QUtf16Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QSjisCodec, QTextCodecFromIOD, QUtf8Codec y QUtf16Codec.
QTextEncoder * QTextCodec::makeEncoder | ( | ) | const [virtual] |
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 only sufficient for the simplest encodings where each Unicode character corresponds to exactly one character.
The caller is responsible for deleting the returned object.
Reimplementado en QUtf16Codec y QUtf16Codec.
virtual QTextEncoder* QTextCodec::makeEncoder | ( | ) | const [virtual] |
Reimplementado en QUtf16Codec y QUtf16Codec.
virtual int QTextCodec::mibEnum | ( | ) | const [pure virtual] |
Implementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QHebrewCodec, QSjisCodec, QTsciiCodec, QUtf8Codec, QUtf16Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec, QLatin1Codec, QLatin15Codec, QTsciiCodec, QUtf8Codec y QUtf16Codec.
int QTextCodec::mibEnum | ( | ) | const [pure virtual] |
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 returns the correct unique value for this function.
Implementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QHebrewCodec, QSjisCodec, QTsciiCodec, QUtf8Codec, QUtf16Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec, QLatin1Codec, QLatin15Codec, QTsciiCodec, QUtf8Codec y QUtf16Codec.
const char * QTextCodec::mimeName | ( | ) | const [virtual] |
Returns the preferred mime name of the encoding as defined in the IANA character-sets encoding file.
Reimplementado en QIsciiCodec, QEucJpCodec, QEucKrCodec, QJisCodec, QHebrewCodec, QSjisCodec, QEucJpCodec, QEucKrCodec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QSimpleTextCodec, QLatin1Codec y QLatin15Codec.
virtual const char* QTextCodec::mimeName | ( | ) | const [virtual] |
Reimplementado en QIsciiCodec, QEucJpCodec, QEucKrCodec, QJisCodec, QHebrewCodec, QSjisCodec, QEucJpCodec, QEucKrCodec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QSimpleTextCodec, QLatin1Codec y QLatin15Codec.
virtual const char* QTextCodec::name | ( | ) | const [pure virtual] |
Implementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QHebrewCodec, QSjisCodec, QTsciiCodec, QUtf8Codec, QUtf16Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec, QLatin1Codec, QLatin15Codec, QTsciiCodec, QUtf8Codec y QUtf16Codec.
const char * QTextCodec::name | ( | ) | const [pure virtual] |
QTextCodec subclasses 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: On 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 hint, such as "iso8859-1" for Latin-1 fonts, "koi8-r" for Russian KOI8 fonts. The default algorithm of heuristicNameMatch() uses name(). Some applications may use this function to present encodings to the end user.
Implementado en QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QHebrewCodec, QSjisCodec, QTsciiCodec, QUtf8Codec, QUtf16Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0201Codec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QFontLaoCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec, QLatin1Codec, QLatin15Codec, QTsciiCodec, QUtf8Codec y QUtf16Codec.
void QTextCodec::setCodecForCStrings | ( | QTextCodec * | c | ) | [inline, static] |
Sets the codec used by QString to convert to and from const char* and QCStrings. If c is 0 (the default), QString assumes Latin-1.
static void QTextCodec::setCodecForCStrings | ( | QTextCodec * | c | ) | [static] |
void QTextCodec::setCodecForLocale | ( | QTextCodec * | c | ) | [static] |
Set the codec to c; this will be returned by codecForLocale(). This might be needed for some applications that want to use their own mechanism for setting the locale.
static void QTextCodec::setCodecForLocale | ( | QTextCodec * | c | ) | [static] |
void QTextCodec::setCodecForTr | ( | QTextCodec * | c | ) | [inline, static] |
Sets the codec used by QObject::tr() on its argument to c. If c is 0 (the default), tr() assumes Latin-1.
If the literal quoted text in the program is not in the Latin-1 encoding, this function can be used to set the appropriate encoding. For example, software developed by Korean programmers might use eucKR for all the text in the program, in which case the main() function might look like this:
int main(int argc, char** argv) { QApplication app(argc, argv); ... install any additional codecs ... QTextCodec::setCodecForTr( QTextCodec::codecForName("eucKR") ); ... }
Note that this is not the way to select the encoding that the user has chosen. For example, to convert an application containing literal English strings to Korean, all that is needed is for the English strings to be passed through tr() and for translation files to be loaded. For details of internationalization, see the Qt internationalization documentation.
static void QTextCodec::setCodecForTr | ( | QTextCodec * | c | ) | [static] |
int QTextCodec::simpleHeuristicNameMatch | ( | const char * | name, |
const char * | hint | ||
) | [static, protected] |
A simple utility function for heuristicNameMatch(): it does some very minor character-skipping so that almost-exact matches score high. name is the text we're matching and hint is used for the comparison.
static int QTextCodec::simpleHeuristicNameMatch | ( | const char * | name, |
const char * | hint | ||
) | [static, protected] |
QString QTextCodec::toUnicode | ( | const QByteArray & | , |
int | len | ||
) | const |
QString QTextCodec::toUnicode | ( | const QByteArray & | a | ) | const |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. a contains the source characters.
QString QTextCodec::toUnicode | ( | const char * | chars | ) | const |
Reimplementado en QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QHebrewCodec, QSjisCodec, QTsciiCodec, QUtf8Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec, QLatin1Codec, QLatin15Codec, QTsciiCodec y QUtf8Codec.
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. a contains the source characters; len contains the number of characters in a to use.
QTextCodec subclasses must reimplement this function or makeDecoder(). It converts the first len characters of chars to Unicode.
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 must reimplement one function or the other to avoid infinite recursion.
Reimplementado en QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QIsciiCodec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QJisCodec, QHebrewCodec, QSjisCodec, QTsciiCodec, QUtf8Codec, QBig5Codec, QBig5hkscsCodec, QEucJpCodec, QEucKrCodec, QFontJis0208Codec, QFontKsc5601Codec, QFontGb2312Codec, QFontGbkCodec, QFontGb18030_0Codec, QFontBig5Codec, QFontBig5hkscsCodec, QGb18030Codec, QGbkCodec, QGb2312Codec, QIsciiCodec, QJisCodec, QHebrewCodec, QSjisCodec, QTextCodecFromIOD, QSimpleTextCodec, QLatin1Codec, QLatin15Codec, QTsciiCodec y QUtf8Codec.
QString QTextCodec::toUnicode | ( | const QByteArray & | a, |
int | len | ||
) | const |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. a contains the source characters; len contains the number of characters in a to use.
QString QTextCodec::toUnicode | ( | const char * | chars | ) | const |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. chars contains the source characters.
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. a contains the source characters.
QString QTextCodec::toUnicode | ( | const QByteArray & | ) | const |
QFont [friend] |
QFontEngineXLFD [friend] |