#include "charconvert.h"


CharConvert::CharConvert()
{

}

QString CharConvert::EUCKRtoUTF8(const char* pData)
{
    QByteArray encodedString = pData;
    QTextCodec* codec = QTextCodec::codecForName("eucKR");
    QString strData = codec->toUnicode(encodedString);

    return strData;
}

QByteArray CharConvert::UTF8toEUCKR(QString encodedString)
{
    QTextCodec* codec = QTextCodec::codecForName("eucKR");
    QByteArray strData = codec->fromUnicode(encodedString);

    //QByteArray testEncoded = encodedString.toStdString().c_str();

    //QString strTest = codec->toUnicode(testEncoded);


    return strData;//.toStdString().c_str();
}



QString CharConvert::Convert(const char* pData, QString strEnc)
{
    if(strEnc=="EUC-KR")
    {
        return UTF8toEUCKR(pData);
    }
    else if(strEnc=="UTF-8")
    {
        return EUCKRtoUTF8(pData);
    }


    return pData;
}
