ANSI 转 Unicode

来源:互联网 发布:mac系统使用方法 编辑:程序博客网 时间:2024/05/18 00:29
void ansi2utf8(char *pInput, char **pOut){    wchar_t pwstr[MAX_PATH];    size_t nLen = 0;    int len = 0;    nLen = strlen(pInput);    len = MultiByteToWideChar(0, 0 , (const char *)pInput, (int)nLen, NULL, 0);    if( len >= MAX_PATH )    {        len = MAX_PATH - 1;    }    MultiByteToWideChar(0, 0, (const char *)pInput, (int)nLen, pwstr, len);    pwstr[len]=0;    len = WideCharToMultiByte(CP_UTF8, NULL, pwstr, wcslen(pwstr), NULL, 0, NULL, NULL);    *pOut = (char *)oef_crt_malloc(len + 1);    WideCharToMultiByte(CP_UTF8, NULL, pwstr, wcslen(pwstr), *pOut, len, NULL, NULL);    (*pOut)[len] = '\0';}

0 0
原创粉丝点击