首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

有木有哪位大侠写了好用的ANSI UNICODE 互转的宏定义。可靠的 安全的,该如何处理

2012-05-20 
有木有哪位大侠写了好用的ANSI UNICODE 互转的宏定义。可靠的 安全的如题。。。。。我想问的是 方便好用,并且可

有木有哪位大侠写了好用的ANSI UNICODE 互转的宏定义。可靠的 安全的
如题。。。。。
我想问的是 方便好用,并且可靠的 宏定义 谢谢

[解决办法]
atlconv.h
[解决办法]
楼上说的就是了 不用ATL或MFC 就把里面的实现全复制下来就行了

[解决办法]
Unicode 转 ASCII

C/C++ code
class Chars{public:    Chars(const CString &str)    {        int length=WideCharToMultiByte(CP_ACP,0,str,-1,NULL,0,NULL,FALSE);        ch=new char[length];        WideCharToMultiByte(CP_ACP,0,str,-1,ch,length,NULL,FALSE);    }    char* GetChars()    {    return ch;    }    ~Chars()    {    delete ch;    }private:    char* ch;};
[解决办法]
C/C++ code
int ustr_astr(WCHAR * unicodestr, char *ansistr ){    int result = 0;    try    {        int needlen = WideCharToMultiByte( CP_ACP, 0, unicodestr, -1, NULL, 0, NULL, NULL );        if( needlen < 0 )        {            return needlen;        }        result = WideCharToMultiByte( CP_ACP, 0, unicodestr, -1, ansistr, needlen + 1, NULL, NULL );        if( result < 0 )        {            return result;        }        return strlen( ansistr );    }    catch( ... )    {    }    return result;}
[解决办法]
不是一二句话,用宏容易出问题

热点排行