Mahoney
4th June 2013, 11:00
Hi. I'm parsing an email message headers. The strings are encoded with Base64 algoritm and are in KOI8-R codepage.
I do the following:
QByteArray a = QByteArray::fromBase64(src);
// here in 'a' I have decoded text in KOI8-R encoding
QTextCodec *pCodec = QTextCodec::codecForName("koi8-r");
QByteArray b = pCodec->toUnicode(a).toUtf8();
// in 'b' I have garbage instead of desired text
What's wrong with the code?
I do the following:
QByteArray a = QByteArray::fromBase64(src);
// here in 'a' I have decoded text in KOI8-R encoding
QTextCodec *pCodec = QTextCodec::codecForName("koi8-r");
QByteArray b = pCodec->toUnicode(a).toUtf8();
// in 'b' I have garbage instead of desired text
What's wrong with the code?