zoukankan      html  css  js  c++  java
  • tinyxml汉字乱码,UTF8转GBK

    在解析读取tinyxml时候,发现读取汉字都是乱码,所以需要转成GBK

     static wstring ConvertUTF8toGBK(const char * strUTF8)
     {
      int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)strUTF8, -1, NULL,0);
      TCHAR * wszUtf8 = new TCHAR[len+1];
      wcscpy(wszUtf8, _T(""));
      MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)strUTF8, -1, wszUtf8, len);
      wstring   strTemp(wszUtf8);
      delete   wszUtf8;
      return   strTemp; 
     }

     

    使用:

     while(NULL != pChildNode)                                         //循环遍历子节点,循环到子节点为空 截止。
     {
      pAttr = pChildNode->FirstAttribute();
      strcpy_s(name, pAttr->Value());

      stringInfo.strID = atoi(name);
      stringInfo.str  = ConvertUTF8toGBK(pChildNode->FirstChild()->Value());
      pChildNode = pChildNode->NextSiblingElement();
      m_stringMap.insert(String_Data(stringInfo.strID, stringInfo.str.c_str()));
     }

  • 相关阅读:
    Python(多进程multiprocessing模块)
    Python(队列)
    Unique Paths
    Unique Paths
    Jump Game II
    Jump Game
    Path Sum II
    Path Sum
    Remove Element
    Implement strStr()
  • 原文地址:https://www.cnblogs.com/yuzhould/p/4454267.html
Copyright © 2011-2022 走看看