Home > Database > Mysql Tutorial > unicode下,读取数据库乱码问题

unicode下,读取数据库乱码问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:13:19
Original
1339 people have browsed it

TCHAR cbContent[512];dyn.GetFieldValue(0,cbConte【本文来自鸿网互联 (http://www.68idc.cn)】nt,512);// 中文会显示乱码AfxMessageBox(cbContent);// 编码转换int nBufferSize = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)cbContent, -1, NULL, 0);wchar_

TCHAR cbContent[512];
dyn.GetFieldValue(0,cbConte【本文来自鸿网互联 (http://www.68idc.cn)】nt,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;
Copy after login

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template