zoukankan      html  css  js  c++  java
  • Qt532_字符编码转换

    1、测试代码:

        // http://blog.csdn.net/changsheng230/article/details/6588447

    QString str = QString::fromLocal8Bit("我是中国人"); QString str2 = QString("本地文本"); // 乱码 qDebug() << str; qDebug() << str2; // Method 2 QTextCodec *codec = QTextCodec::codecForName("GBK"); // get the codec for KOI8-R //QString locallyEncoded = codec->toUnicode( "显示中文" ); QString locallyEncoded = codec->toUnicode( "我是中国人" ); qDebug() << locallyEncoded << endl; codec = QTextCodec::codecForName("gbk"); // get the codec for KOI8-R locallyEncoded = codec->toUnicode( "我是中国人" ); qDebug() << locallyEncoded << endl; wchar_t *pwc = L"我是中国人"; for (size_t i=0; i<wcslen(pwc); i++) { ushort us = pwc[i]; qDebug() << " " << QString::number(us, 16).leftJustified(2, '0'); } qDebug() << ""; QChar *pcs = (QChar*)str.unicode(); for (int i=0; i<str.length(); i++) { QChar c = pcs[i]; ushort us = c.unicode(); qDebug() << " " << QString::number(us, 16).leftJustified(2, '0'); } qDebug() << ""; //QChar *pcs = locallyEncoded.data(); pcs = (QChar*)locallyEncoded.unicode(); for (int i=0; i<locallyEncoded.length(); i++) { QChar c = pcs[i]; ushort us = c.unicode(); qDebug() << " " << QString::number(us, 16).leftJustified(2, '0'); }

    2、

  • 相关阅读:
    centos7上以RPM方式安装MySQL5.6
    区别和详解:jQuery extend()和jQuery.fn.extend()
    jQuery笔记总结
    CSS Hack的一些知识
    12种不宜使用的javascript的语法
    64位Win7系统下vs2010调试无法连接oracle解决办法
    HashCode()与equals()深入理解
    Java ArrayList自动扩容机制
    Java基础知识
    MySQL的MVCC机制
  • 原文地址:https://www.cnblogs.com/cppskill/p/5531838.html
Copyright © 2011-2022 走看看