Detailed Description
The QGsmCodec class represents the text codec for the GSM 7-bit encoding of Latin-1
The GSM specifications for SMS use a compact 7-bit encoding to represent Latin-1 characters, compared to the more usual 8-bit ISO-8859-1 encoding used on many computer systems.
The QGsmCodec class enables conversion back and forth between the GSM encoding and the normal Unicode encoding used by Qtopia.
Application programs will rarely need to use this class, because the QSMSMessage class automatically converts between 7-bit and Unicode encodings as necessary.
If an application program does need to use this class, it should call QAtUtils::codec() to obtain an instance of the codec. Constructing QGsmCodec objects directly is not recommended, due to how QTextCodec registers and deregisters codec implementations.
The following example converts the input string into the compact 7-bit encoding within output.
QString input = "...";
QByteArray output = QAtUtils::codec("gsm")->fromUnicode(input);
This codec implementation conforms to 3GPP TS 03.38 and 3GPP TS 07.05, including the extension tables from 3GPP TS 03.38.
See also QSMSMessage and QAtUtils::codec().
Member Function Documentation
QGsmCodec::QGsmCodec ( bool noLoss = false )
Construct a new GSM text codec. If noLoss is true, then the codec should not encode characters that may result in an ambiguous decoding.
This constructor should not be used directly. Instead, call QAtUtils::codec() to obtain an instance of this codec implementation. This is due to how QTextCodec registers and deregisters codec implementations. The codec names to use with QAtUtils::codec() are gsm and gsm-noloss, for the regular and no-loss versions of the codec.
See also QAtUtils::codec().
QGsmCodec::~QGsmCodec ()
Destruct a GSM text codec. This should not be used directly by application programs.
QByteArray QGsmCodec::convertFromUnicode ( const QChar * in, int length, ConverterState * state ) const [virtual protected]
Convert the length characters at in into 7-bit GSM. The invalidChars field of state will be incremented if there are invalid characters within in.
Reimplemented from QTextCodec.
See also convertToUnicode().
QString QGsmCodec::convertToUnicode ( const char * in, int length, ConverterState * state ) const [virtual protected]
Convert the length bytes at in into Unicode. The invalidChars field of state will be incremented if there are invalid characters within in.
Reimplemented from QTextCodec.
See also convertFromUnicode().
int QGsmCodec::mibEnum () const [virtual]
Returns the MIB value associated with this codec.
Reimplemented from QTextCodec.
QByteArray QGsmCodec::name () const [virtual]
Returns the name of this codec.
Reimplemented from QTextCodec.
char QGsmCodec::singleFromUnicode ( QChar c ) [static]
Convert a single Unicode character c into GSM 7-bit. Returns 0x10 if the character cannot be mapped. Use of this function is discouraged.
Note: this will not work for two-byte GSM encodings. Use twoByteFromUnicode() instead.
See also singleToUnicode() and twoByteFromUnicode().
QChar QGsmCodec::singleToUnicode ( char ch ) [static]
Convert a single GSM 7-bit character ch into Unicode. Use of this function is discouraged.
Note: this will not work for two-byte GSM encodings. Use twoByteToUnicode() instead.
See also singleFromUnicode() and twoByteToUnicode().
unsigned short QGsmCodec::twoByteFromUnicode ( QChar ch ) [static]
Convert a Unicode character ch into its GSM-encoded counterpart. The return value will be greater than 256 if the Unicode character should be encoded as two bytes.
See also twoByteToUnicode().
QChar QGsmCodec::twoByteToUnicode ( unsigned short ch ) [static]
Convert a single GSM-encoded character into its Unicode counterpart. If ch is greater than 256, then it represents a two-byte sequence.
See also twoByteFromUnicode().