Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
QTextCodec Class Referenceabstract

Provides conversion between text encodings. More...

#include <qtextcodec.h>

Inheritance diagram for QTextCodec:
QLatin1Codec QSimpleTextCodec QTextCodecFromIOD QUtf16Codec QUtf8Codec

Public Member Functions

virtual ~QTextCodec ()
 
virtual const char * name () const =0
 
virtual int mibEnum () const =0
 
virtual QTextDecodermakeDecoder () const
 
virtual QTextEncodermakeEncoder () 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 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
 

Static Public Member Functions

static QTextCodecloadCharmap (QIODevice *)
 
static QTextCodecloadCharmapFile (QString filename)
 
static QTextCodeccodecForMib (int mib)
 
static QTextCodeccodecForName (const char *hint, int accuracy=0)
 
static QTextCodeccodecForContent (const char *chars, int len)
 
static QTextCodeccodecForIndex (int i)
 
static QTextCodeccodecForLocale ()
 
static void deleteAllCodecs ()
 
static const char * locale ()
 

Protected Member Functions

 QTextCodec ()
 

Static Protected Member Functions

static int simpleHeuristicNameMatch (const char *name, const char *hint)
 

Detailed Description

Provides conversion between text encodings.

By making objects of subclasses of QTextCodec, support for new text encodings can be added to Qt.

The abstract virtual functions describe the encoder to the system and the coder is used as required in the different text file formats supported QTextStream and, under X11 for the locale-specific character input and output (under Windows NT codecs are not needed for GUI I/O since the system works with Unicode already, and Windows 95/98 has built-in convertors for the 8-bit local encoding).

More recently created QTextCodec objects take precedence over earlier ones.

To add support for another 8-bit encoding to Qt, make a subclass or QTextCodec and implement at least the following methods:

const char* name() const
Return the official name for the encoding.
int mibEnum() const
Return the MIB enum for the encoding if it is listed in the IANA character-sets encoding file.

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

QTextDecoder* makeDecoder() const
Return a QTextDecoder that remembers incomplete multibyte sequence prefixes or other required state.

If the encoding does not require state, you should implement:

QString toUnicode(const char* chars, int len) const
Converts len characters from chars to Unicode.

The base QTextCodec class has default implementations of the above two functions, but they are mutually recursive, so you must re-implement at least one of them, or both for improved efficiency.

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:

QTextEncoder* makeEncoder() const
Return a QTextDecoder.
QCString fromUnicode(const QString& uc, int& lenInOut ) const;
Converts lenInOut characters (of type QChar) from the start of the string uc, returning a QCString result, and also returning the length of the result in lenInOut.

Again, these are mutually recursive so only one needs to be implemented, or both if better efficiency is possible.

Finally, you must implement:

int heuristicContentMatch(const char* chars, int len) const
Gives a value indicating how likely it is that len characters from chars are in the encoding.

A good model for this function is the QWindowsLocalCodec::heuristicContentMatch function found in the Qt sources.

A QTextCodec subclass might have improved performance if you also re-implement:

bool canEncode( QChar ) const
Test if a Unicode character can be encoded.
bool canEncode( const QString& ) const
Test if a string of Unicode characters can be encoded.
int heuristicNameMatch(const char* hint) const
Test if a possibly non-standard name is referring to the codec.

Definition at line 62 of file qtextcodec.h.

Constructor & Destructor Documentation

QTextCodec::~QTextCodec ( )
virtual

Destructs the QTextCodec. Note that you should not delete codecs yourself - once created they become the responsibility of Qt to delete.

Definition at line 258 of file qtextcodec.cpp.

259 {
260  if ( !destroying_is_ok )
261  qWarning("QTextCodec::~QTextCodec() called by application");
262  if ( all )
263  all->remove( this );
264 }
void qWarning(const char *msg,...)
Definition: qglobal.cpp:409
static bool destroying_is_ok
Definition: qtextcodec.cpp:64
static QInternalList< QTextCodec > * all
Definition: qtextcodec.cpp:63
QTextCodec::QTextCodec ( )
protected

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).

Definition at line 246 of file qtextcodec.cpp.

247 {
248  setup();
249  all->insert(0,this);
250 }
static QInternalList< QTextCodec > * all
Definition: qtextcodec.cpp:63
static void setup()
Definition: qtextcodec.cpp:110

Member Function Documentation

bool QTextCodec::canEncode ( QChar  ch) const
virtual

Returns TRUE if the unicode character ch can be fully encoded with this codec. The default implementation tests if the result of toUnicode(fromUnicode(ch)) is the original ch. Subclasses may be able to improve the efficiency.

Definition at line 835 of file qtextcodec.cpp.

836 {
837  return toUnicode(fromUnicode(ch)) == ch;
838 }
virtual QCString fromUnicode(const QString &uc, int &lenInOut) const
Definition: qtextcodec.cpp:783
virtual QString toUnicode(const char *chars, int len) const
Definition: qtextcodec.cpp:757
bool QTextCodec::canEncode ( const QString s) const
virtual

Returns TRUE if the unicode string s can be fully encoded with this codec. The default implementation tests if the result of toUnicode(fromUnicode(s)) is the original s. Subclasses may be able to improve the efficiency.

Definition at line 846 of file qtextcodec.cpp.

847 {
848  return toUnicode(fromUnicode(s)) == s;
849 }
virtual QCString fromUnicode(const QString &uc, int &lenInOut) const
Definition: qtextcodec.cpp:783
virtual QString toUnicode(const char *chars, int len) const
Definition: qtextcodec.cpp:757
static QCString * s
Definition: config.cpp:1042
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.

See also
heuristicContentMatch()

Definition at line 653 of file qtextcodec.cpp.

654 {
655  setup();
657  QTextCodec* result = 0;
658  int best=0;
659  for ( QTextCodec* cursor; (cursor=i); ++i ) {
660  int s = cursor->heuristicContentMatch(chars,len);
661  if ( s > best ) {
662  best = s;
663  result = cursor;
664  }
665  }
666  return result;
667 }
static QCString result
static QInternalList< QTextCodec > * all
Definition: qtextcodec.cpp:63
Provides conversion between text encodings.
Definition: qtextcodec.h:62
static QCString * s
Definition: config.cpp:1042
static void setup()
Definition: qtextcodec.cpp:110
QTextCodec * QTextCodec::codecForIndex ( int  i)
static

Returns the QTextCodec i places from the more recently inserted, or NULL if there is no such QTextCodec. Thus, codecForIndex(0) returns the most recently created QTextCodec.

Definition at line 343 of file qtextcodec.cpp.

344 {
345  setup();
346  return (uint)i >= all->count() ? 0 : all->at(i);
347 }
static QInternalList< QTextCodec > * all
Definition: qtextcodec.cpp:63
unsigned uint
Definition: qglobal.h:351
static void setup()
Definition: qtextcodec.cpp:110
QTextCodec * QTextCodec::codecForLocale ( )
static

Returns a pointer to the codec most suitable for this locale.

Definition at line 542 of file qtextcodec.cpp.

543 {
544  if ( localeMapper )
545  return localeMapper;
546 
547  setup();
548 
549 #ifdef _OS_WIN32_
550  localeMapper = new QWindowsLocalCodec;
551 #else
552  // Very poorly defined and followed standards causes lots of code
553  // to try to get all the cases...
554 
555  char * lang = qstrdup( getenv("LANG") );
556 
557  char * p = lang ? strchr( lang, '.' ) : 0;
558  if ( !p || *p != '.' ) {
559  // Some versions of setlocale return encoding, others not.
560  char *ctype = qstrdup( setlocale( LC_CTYPE, 0 ) );
561  // Some Linux distributions have broken locales which will return
562  // "C" for LC_CTYPE
563  if ( qstrcmp( ctype, "C" ) == 0 ) {
564  delete [] ctype;
565  } else {
566  if ( lang )
567  delete [] lang;
568  lang = ctype;
569  p = lang ? strchr( lang, '.' ) : 0;
570  }
571  }
572 
573  if( p && *p == '.' ) {
574  // if there is an encoding and we don't know it, we return 0
575  // User knows what they are doing. Codecs will believe them.
576  localeMapper = codecForName( lang );
577  if ( !localeMapper ) {
578  // Use or codec disagree.
579  localeMapper = codecForName( p+1 );
580  }
581  }
582  if ( !localeMapper || !(p && *p == '.') ) {
583  // if there is none, we default to 8859-1
584  // We could perhaps default to 8859-15.
585  if ( try_locale_list( iso8859_2locales, lang ) )
586  localeMapper = codecForName( "ISO 8859-2" );
587  else if ( try_locale_list( iso8859_3locales, lang ) )
588  localeMapper = codecForName( "ISO 8859-3" );
589  else if ( try_locale_list( iso8859_4locales, lang ) )
590  localeMapper = codecForName( "ISO 8859-4" );
591  else if ( try_locale_list( iso8859_5locales, lang ) )
592  localeMapper = codecForName( "ISO 8859-5" );
593  else if ( try_locale_list( iso8859_6locales, lang ) )
594  localeMapper = codecForName( "ISO 8859-6-I" );
595  else if ( try_locale_list( iso8859_7locales, lang ) )
596  localeMapper = codecForName( "ISO 8859-7" );
597  else if ( try_locale_list( iso8859_8locales, lang ) )
598  localeMapper = codecForName( "ISO 8859-8-I" );
599  else if ( try_locale_list( iso8859_9locales, lang ) )
600  localeMapper = codecForName( "ISO 8859-9" );
601  else if ( try_locale_list( iso8859_15locales, lang ) )
602  localeMapper = codecForName( "ISO 8859-15" );
603  else if ( try_locale_list( tis_620locales, lang ) )
604  localeMapper = codecForName( "ISO 8859-11" );
605  else if ( try_locale_list( koi8_ulocales, lang ) )
606  localeMapper = codecForName( "KOI8-U" );
607  else if ( try_locale_list( probably_koi8_rlocales, lang ) )
608  localeMapper = ru_RU_hack( lang );
609  else if (!lang || !(localeMapper = codecForName(lang) ))
610  localeMapper = codecForName( "ISO 8859-1" );
611  }
612  delete[] lang;
613 #endif
614 
615  return localeMapper;
616 }
static const char *const koi8_ulocales[]
Definition: qtextcodec.cpp:475
static const char *const iso8859_8locales[]
Definition: qtextcodec.cpp:466
static const char *const iso8859_5locales[]
Definition: qtextcodec.cpp:456
static const char *const iso8859_2locales[]
Definition: qtextcodec.cpp:444
static bool try_locale_list(const char *const locale[], const char *lang)
Definition: qtextcodec.cpp:482
static const char *const probably_koi8_rlocales[]
Definition: qtextcodec.cpp:501
static const char *const iso8859_3locales[]
Definition: qtextcodec.cpp:450
static const char *const iso8859_9locales[]
Definition: qtextcodec.cpp:469
std::string getenv(std::string const &name)
Definition: getenv.cc:15
p
Definition: test.py:223
static const char *const tis_620locales[]
Definition: qtextcodec.cpp:478
static const char *const iso8859_4locales[]
Definition: qtextcodec.cpp:453
static QTextCodec * ru_RU_hack(const char *i)
Definition: qtextcodec.cpp:508
static QTextCodec * codecForName(const char *hint, int accuracy=0)
Definition: qtextcodec.cpp:626
static const char *const iso8859_6locales[]
Definition: qtextcodec.cpp:460
char * qstrdup(const char *str)
Definition: qcstring.cpp:548
static const char *const iso8859_7locales[]
Definition: qtextcodec.cpp:463
static QTextCodec * localeMapper
Definition: qtextcodec.cpp:533
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
static void setup()
Definition: qtextcodec.cpp:110
static const char *const iso8859_15locales[]
Definition: qtextcodec.cpp:472
QTextCodec * QTextCodec::codecForMib ( int  mib)
static

Returns the QTextCodec which matches the MIBenum mib.

Definition at line 354 of file qtextcodec.cpp.

355 {
356  setup();
359  for ( ; (result=i); ++i ) {
360  if ( result->mibEnum()==mib )
361  break;
362  }
363  return result;
364 }
static QCString result
int mib
static QInternalList< QTextCodec > * all
Definition: qtextcodec.cpp:63
virtual int mibEnum() const =0
Provides conversion between text encodings.
Definition: qtextcodec.h:62
static void setup()
Definition: qtextcodec.cpp:110
QTextCodec * QTextCodec::codecForName ( const char *  hint,
int  accuracy = 0 
)
static

Searches all installed QTextCodec objects, returning the one which best matches given name. Returns NULL if no codec has a match closeness above accuracy.

See also
heuristicNameMatch()

Definition at line 626 of file qtextcodec.cpp.

627 {
628  setup();
630  QTextCodec* result = 0;
631  int best=accuracy;
632  for ( QTextCodec* cursor; (cursor=i); ++i ) {
633  int s = cursor->heuristicNameMatch(hint);
634  if ( s > best ) {
635  best = s;
636  result = cursor;
637  }
638  }
639  return result;
640 }
static QCString result
static QInternalList< QTextCodec > * all
Definition: qtextcodec.cpp:63
Provides conversion between text encodings.
Definition: qtextcodec.h:62
static QCString * s
Definition: config.cpp:1042
static void setup()
Definition: qtextcodec.cpp:110
void QTextCodec::deleteAllCodecs ( )
static

Deletes all the created codecs.

Warning
Do not call this function.

QApplication 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.

If 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.

Definition at line 81 of file qtextcodec.cpp.

82 {
83  if ( !all )
84  return;
85 
88  all = 0;
89  ball->clear();
90  delete ball;
92 }
const bool FALSE
Definition: qglobal.h:370
static bool destroying_is_ok
Definition: qtextcodec.cpp:64
static QInternalList< QTextCodec > * all
Definition: qtextcodec.cpp:63
const bool TRUE
Definition: qglobal.h:371
QCString QTextCodec::fromUnicode ( const QString uc,
int &  lenInOut 
) const
virtual

Subclasses of QTextCodec 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.

The 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 lenInOut.

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.

Reimplemented in QLatin1Codec, QSimpleTextCodec, QTextCodecFromIOD, and QUtf8Codec.

Definition at line 783 of file qtextcodec.cpp.

784 {
785  QTextEncoder* i = makeEncoder();
786  QCString result = i->fromUnicode(uc, lenInOut);
787  delete i;
788  return result;
789 }
static QCString result
virtual QTextEncoder * makeEncoder() const
Definition: qtextcodec.cpp:740
State-based encoder.
Definition: qtextcodec.h:50
virtual QCString fromUnicode(const QString &uc, int &lenInOut)=0
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.

Definition at line 794 of file qtextcodec.cpp.

795 {
796  int l = uc.length();
797  return fromUnicode(uc,l);
798 }
virtual QCString fromUnicode(const QString &uc, int &lenInOut) const
Definition: qtextcodec.cpp:783
static QStrList * l
Definition: config.cpp:1044
uint length() const
Definition: qstring.h:679
int QTextCodec::heuristicContentMatch ( const char *  chars,
int  len 
) const
pure virtual

Subclasses of QTextCodec 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. 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 len. Thus, most decoders will return -1, 0, or -len.

The characters are not null terminated.

See also
codecForContent().

Implemented in QLatin1Codec, QSimpleTextCodec, QTextCodecFromIOD, QUtf16Codec, and QUtf8Codec.

int QTextCodec::heuristicNameMatch ( const char *  hint) const
virtual

Returns a value indicating how likely this decoder is for decoding some format that has the given name.

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.

Reimplemented in QLatin1Codec, QSimpleTextCodec, and QTextCodecFromIOD.

Definition at line 277 of file qtextcodec.cpp.

278 {
279  return simpleHeuristicNameMatch(name(),hint);
280 }
virtual const char * name() const =0
static int simpleHeuristicNameMatch(const char *name, const char *hint)
Definition: qtextcodec.cpp:316
QTextCodec * QTextCodec::loadCharmap ( QIODevice iod)
static

Reads a POSIX2 charmap definition from iod. The parser recognizes the following lines:

   <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

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 in memory shared by all applications simultaneously using Qt.

See also
loadCharmapFile()

Definition at line 1279 of file qtextcodec.cpp.

1280 {
1282  if ( !r->ok() ) {
1283  delete r;
1284  r = 0;
1285  }
1286  return r;
1287 }
bool ok() const
QTextCodec * QTextCodec::loadCharmapFile ( QString  filename)
static

A convenience function for loadCharmap().

Definition at line 1292 of file qtextcodec.cpp.

1293 {
1294  QFile f(filename);
1295  if (f.open(IO_ReadOnly)) {
1297  if ( !r->ok() )
1298  delete r;
1299  else
1300  return r;
1301  }
1302  return 0;
1303 }
bool ok() const
#define IO_ReadOnly
Definition: qiodevice.h:61
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
const char * QTextCodec::locale ( )
static

Returns a string representing the current language.

Definition at line 1311 of file qtextcodec.cpp.

1312 {
1313  static QCString lang;
1314  if ( lang.isEmpty() ) {
1315  lang = getenv( "LANG" ); //########Windows??
1316  if ( lang.isEmpty() )
1317  lang = "C";
1318  }
1319  return lang;
1320 }
bool isEmpty() const
Definition: qcstring.h:189
std::string getenv(std::string const &name)
Definition: getenv.cc:15
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 sufficient for only the simplest encodings where each byte corresponds to exactly one Unicode character.

The caller is responsible for deleting the returned object.

Reimplemented in QTextCodecFromIOD, QUtf16Codec, and QUtf8Codec.

Definition at line 726 of file qtextcodec.cpp.

727 {
728  return new QTextStatelessDecoder(this);
729 }
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 sufficient for only the simplest encodings where each Unicode character corresponds to exactly one char.

The caller is responsible for deleting the returned object.

Reimplemented in QUtf16Codec.

Definition at line 740 of file qtextcodec.cpp.

741 {
742  return new QTextStatelessEncoder(this);
743 }
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 return the correct unique value for this function.

Implemented in QLatin1Codec, QSimpleTextCodec, QTextCodecFromIOD, QUtf16Codec, and QUtf8Codec.

const char * QTextCodec::name ( ) const
pure virtual

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:

  • 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.

Implemented in QLatin1Codec, QSimpleTextCodec, QTextCodecFromIOD, QUtf16Codec, and QUtf8Codec.

int QTextCodec::simpleHeuristicNameMatch ( const char *  name,
const char *  hint 
)
staticprotected

A simple utility function for heuristicNameMatch() - it does some very minor character-skipping so that almost-exact matches score high.

Definition at line 316 of file qtextcodec.cpp.

317 {
318  // if they're the same, return a perfect score.
319  if ( name && hint && qstrcmp( name, hint ) == 0 )
320  return qstrlen( hint );
321 
322  // if the letters and numbers are the same, we have an "almost"
323  // perfect match.
324  QString h( lettersAndNumbers( hint ) );
326  if ( h == n )
327  return qstrlen( hint )-1;
328 
329  if ( h.stripWhiteSpace() == n.stripWhiteSpace() )
330  return qstrlen( hint )-2;
331 
332  // could do some more here, but I don't think it's worth it
333 
334  return 0;
335 }
virtual const char * name() const =0
static QString lettersAndNumbers(const char *input)
Definition: qtextcodec.cpp:286
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
std::void_t< T > n
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
QString QTextCodec::toUnicode ( const char *  chars,
int  len 
) const
virtual

Subclasses of QTextCodec 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.

Reimplemented in QLatin1Codec, QSimpleTextCodec, and QTextCodecFromIOD.

Definition at line 757 of file qtextcodec.cpp.

758 {
759  QTextDecoder* i = makeDecoder();
760  QString result = i->toUnicode(chars,len);
761  delete i;
762  return result;
763 }
virtual QTextDecoder * makeDecoder() const
Definition: qtextcodec.cpp:726
static QCString result
State-based decoder.
Definition: qtextcodec.h:56
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
virtual QString toUnicode(const char *chars, int len)=0
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.

Definition at line 803 of file qtextcodec.cpp.

804 {
805  int l = a.size();
806  if( l > 0 && a.data()[l - 1] == '\0' ) l--;
807  l = QMIN( l, len );
808  return toUnicode( a.data(), l );
809 }
static QStrList * l
Definition: config.cpp:1044
#define QMIN(a, b)
Definition: qglobal.h:391
type * data() const
Definition: qarray.h:63
virtual QString toUnicode(const char *chars, int len) const
Definition: qtextcodec.cpp:757
uint size() const
Definition: qarray.h:65
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.

Definition at line 814 of file qtextcodec.cpp.

815 {
816  int l = a.size();
817  if( l > 0 && a.data()[l - 1] == '\0' ) l--;
818  return toUnicode( a.data(), l );
819 }
static QStrList * l
Definition: config.cpp:1044
type * data() const
Definition: qarray.h:63
virtual QString toUnicode(const char *chars, int len) const
Definition: qtextcodec.cpp:757
uint size() const
Definition: qarray.h:65
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.

Definition at line 824 of file qtextcodec.cpp.

825 {
826  return toUnicode(chars,qstrlen(chars));
827 }
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
virtual QString toUnicode(const char *chars, int len) const
Definition: qtextcodec.cpp:757

The documentation for this class was generated from the following files: