Qt UTF8 to ANSI coverting and file saving

256 Views Asked by At

Here is test code..

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QByteArray fileBuffer("일이");

    QFile saveFile("test.txt");
    if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text))
        return a.exec();

    QTextStream stream(&saveFile);
    QTextCodec *codec = QTextCodec::codecForName("EUCKR");
    QByteArray encodedString = codec->fromUnicode(fileBuffer);
    stream << encodedString;
    stream.flush();
    saveFile.close();
    return a.exec();
}

I thought that test.txt encoded EUC-KR . But when read by note pad (Window application) encoding type is UTF-8, not ANSI.

What is the problem??

I should text file which stored hex code encoded by EUC KR .

0

There are 0 best solutions below