Public Member Functions | Private Attributes | List of all members
QUtf16Decoder Class Reference
Inheritance diagram for QUtf16Decoder:
QTextDecoder

Public Member Functions

 QUtf16Decoder ()
 
QString toUnicode (const char *chars, int len)
 
- Public Member Functions inherited from QTextDecoder
virtual ~QTextDecoder ()
 

Private Attributes

uchar buf
 
bool half
 
bool swap
 
bool headerdone
 

Detailed Description

Definition at line 219 of file qutfcodec.cpp.

Constructor & Destructor Documentation

QUtf16Decoder::QUtf16Decoder ( )
inline

Definition at line 226 of file qutfcodec.cpp.

227  {
228  }
const bool FALSE
Definition: qglobal.h:370

Member Function Documentation

QString QUtf16Decoder::toUnicode ( const char *  chars,
int  len 
)
inlinevirtual

Converts the first len bytes at chars to Unicode, returning the result.

If not all characters are used (eg. only part of a multi-byte encoding is at the end of the characters), the decoder remembers enough state to continue with the next call to this function.

Implements QTextDecoder.

Definition at line 230 of file qutfcodec.cpp.

231  {
232  QString r;
233 
234  while ( len-- ) {
235  if ( half ) {
236  QChar ch;
237  if ( swap ) {
238  ch.row() = *chars++;
239  ch.cell() = buf;
240  } else {
241  ch.row() = buf;
242  ch.cell() = *chars++;
243  }
244  if ( !headerdone ) {
245  if ( ch == QChar::byteOrderSwapped ) {
246  swap = !swap;
247  } else if ( ch == QChar::byteOrderMark ) {
248  // Ignore ZWNBSP
249  } else {
250  r += ch;
251  }
252  headerdone = TRUE;
253  } else
254  r += ch;
255  half = FALSE;
256  } else {
257  buf = *chars++;
258  half = TRUE;
259  }
260  }
261 
262  return r;
263  }
const bool FALSE
Definition: qglobal.h:370
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
The QChar class provides a light-weight Unicode character.
Definition: qstring.h:56
uchar & cell()
Definition: qstring.h:167
QT_STATIC_CONST QChar byteOrderMark
Definition: qstring.h:70
QT_STATIC_CONST QChar byteOrderSwapped
Definition: qstring.h:71
uchar & row()
Definition: qstring.h:168
const bool TRUE
Definition: qglobal.h:371

Member Data Documentation

uchar QUtf16Decoder::buf
private

Definition at line 220 of file qutfcodec.cpp.

bool QUtf16Decoder::half
private

Definition at line 221 of file qutfcodec.cpp.

bool QUtf16Decoder::headerdone
private

Definition at line 223 of file qutfcodec.cpp.

bool QUtf16Decoder::swap
private

Definition at line 222 of file qutfcodec.cpp.


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