unicode下,讀取資料庫亂碼問題,unicode亂碼

來源:互聯網
上載者:User

unicode下,讀取資料庫亂碼問題,unicode亂碼

 TCHAR cbContent[512];
          dyn.GetFieldValue(0,cbContent,512);

               // 中文會顯示亂碼

               AfxMessageBox(cbContent);

               // 編碼轉換
               int nBufferSize = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)cbContent, -1, NULL, 0);
               wchar_t *pBuffer = new wchar_t[nBufferSize+1];
               MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)cbContent, -1 , pBuffer, nBufferSize*sizeof(wchar_t));               

               // 顯示正常

               AfxMessageBox(pBuffer);

              delete[] pBuffer;

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.