根据QT帮助文档可知:
GB2312 -简体中文字符集,应用范围广,基本包含所有中文;
GB18030 -对GB2312的扩展,兼容GB2312,用单、双、四字节进行编码
编码格式汇总:
Big5 -- Chinese
eucJP -- Japanese
eucKR -- Korean
GBK -- 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
CP850
CP874
CP1250 -- Central European
CP1251 -- Cyrillic
CP1252 -- Western
CP1253 -- Greek
CP1254 -- Turkish
CP1255 -- Hebrew
CP1256 -- Arabic
CP1257 -- Baltic
CP1258
Apple Roman
TIS-620 -- Thai
QTextCodec类提供两种编码方式的转换
注:QCString,继承于QByteArray,是以0结尾的char*字符数组类型,QCString是QMemArray,它使用带引用计数的明显共享
QString支持Unicode数据类型,通常不以0结尾
如果数据是以零结尾的八位数据,请使用QCString;
如果它是没有结尾的(也就是包含0)八位数据,请使用QByteArray;
如果它是文本,请使用QString。-浮生听声晚
KOI8-R - Unicode
QCString locallyEncoded = "..."; // text to convert
QTextCodec *codec = QTextCodec::codecForName("KOI8-R"); // get the codec for KOI8-R
QString unicodeString = codec->toUnicode( locallyEncoded );
Unicode - KOI8-R
QString unicodeString = "..."; // any Unicode text
QTextCodec *codec = QTextCodec::codecForName("KOI8-R"); // get the codec for KOI8-R
QCString locallyEncoded = codec->fromUnicode( unicodeString );