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

Public Member Functions

 QUtf16Encoder ()
 
QCString fromUnicode (const QString &uc, int &len_in_out)
 
- Public Member Functions inherited from QTextEncoder
virtual ~QTextEncoder ()
 

Private Attributes

bool headerdone
 

Detailed Description

Definition at line 194 of file qutfcodec.cpp.

Constructor & Destructor Documentation

QUtf16Encoder::QUtf16Encoder ( )
inline

Definition at line 197 of file qutfcodec.cpp.

197  : headerdone(FALSE)
198  {
199  }
const bool FALSE
Definition: qglobal.h:370

Member Function Documentation

QCString QUtf16Encoder::fromUnicode ( const QString uc,
int &  lenInOut 
)
inlinevirtual

Converts lenInOut characters (not bytes) from uc, producing a QCString. lenInOut will also be set to the length of the result (in bytes).

The encoder is free to record state to use when subsequent calls are made to this function (for example, it might change modes with escape sequences if needed during the encoding of one string, then assume that mode applies when a subsequent call begins).

Implements QTextEncoder.

Definition at line 201 of file qutfcodec.cpp.

202  {
203  if ( headerdone ) {
204  len_in_out = uc.length()*(int)sizeof(QChar);
205  QCString d(len_in_out);
206  memcpy(d.rawData(),uc.unicode(),len_in_out);
207  return d;
208  } else {
209  headerdone = TRUE;
210  len_in_out = (1+uc.length())*(int)sizeof(QChar);
211  QCString d(len_in_out);
212  memcpy(d.rawData(),&QChar::byteOrderMark,sizeof(QChar));
213  memcpy(d.rawData()+sizeof(QChar),uc.unicode(),uc.length()*sizeof(QChar));
214  return d;
215  }
216  }
const QChar * unicode() const
Definition: qstring.h:508
The QChar class provides a light-weight Unicode character.
Definition: qstring.h:56
uint length() const
Definition: qstring.h:679
QT_STATIC_CONST QChar byteOrderMark
Definition: qstring.h:70
const bool TRUE
Definition: qglobal.h:371

Member Data Documentation

bool QUtf16Encoder::headerdone
private

Definition at line 195 of file qutfcodec.cpp.


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