基本上我需要将UTF-8字符串转换为windows-1256,并使用以下代码执行:
#include <windows.h>
#include <stdio.h>
char* convert(char* pszStringToConvert)
{
int len = strlen(pszStringToConvert); // get string length
wchar_t* pwsz = new wchar_t[len+1]; // allocate storage for temporary UNICODE string
MultiByteToWideChar(65001,0, pszStringToConvert, len, pwsz, len);
WideCharToMultiByte(1256,0, pwsz, len, pszStringToConvert, len, NULL, FALSE);
return pszStringToConvert;
}
int main()
{
char* arabic ="السلام";
char* win = convert(arabic);
printf("%s\n%",win);
return 0;
}
我的源代码是
arabic =“السلام”
但遗憾的是我的结果字符串变为
win =آسٔاÙ......
我在这里做错了什么?