嵌入式Qt下UTF8转GBK

来源:互联网 发布:数据防泄漏国内厂家 编辑:程序博客网 时间:2024/06/01 07:27
QTextCodec *utf8 = QTextCodec::codecForName("UTF-8");
    QTextCodec *gbk = QTextCodec::codecForName("GBK");
    QString str = "请上车";

    qDebug()<<"str:"<<str.toLatin1().toHex()<<"\ngbk:"<<gbk->fromUnicode(utf8->toUnicode(str.toLatin1())).toHex();
原创粉丝点击