Windows下Unicode(UCS2),UTF8,GBK(GB2312)互转
2012-08-14 19:00 java环境变量 阅读(645) 评论(0) 编辑 收藏 举报Windows下提供了两个编码转换函数:WideCharToMultiByte和MultiByteToWideChar。
用它们可实现Unicode(UCS2),UTF8,GBK(GB2312)互转。这两个函数的原型是:
int WINAPI MultiByteToWideChar( __in UINT CodePage, __in DWORD dwFlags, __in_bcount(cbMultiByte) LPCSTR lpMultiByteStr, __in int cbMultiByte, __out_ecount_opt(cchWideChar) __transfer(lpMultiByteStr) LPWSTR lpWideCharStr, __in int cchWideChar); int WINAPI WideCharToMultiByte( __in UINT CodePage, __in DWORD dwFlags, __in_ecount(cchWideChar) LPCWSTR lpWideCharStr, __in int cchWideChar, __out_bcount_opt(cbMultiByte) __transfer(lpWideCharStr) LPSTR lpMultiByteStr, __in int cbMultiByte, __in_opt LPCSTR lpDefaultChar, __out_opt LPBOOL lpUsedDefaultChar);