现在的位置: 首页 > 综合 > 正文

字符编码ANSI和Unicode的比较

2013年08月23日 ⁄ 综合 ⁄ 共 482字 ⁄ 字号 评论关闭

char szA[100];             //An ANSI string buffer
WCHAR szW[100];            //A Unicode string buffer

 

//Normal sprintf:all strings are ANSI
sprintf(szA, "%s","ANSI Str");

 

//Converts Unicode string to ANSI
sprintf(szA,"%S",L"Unicode Str");

 

//Normal swprintf:all strings are Unicode
swprintf(szW,L"%s",L"Unicode Str");

 

//Converts ANSI string to Unicode
swprintf(szW,L"%S", "ANSI Str");

 

如何确定一个文件是ANSI || UNICODE 文件:
文本文件是包含A N S I 字符还是U n i c o d e 字符。I s Te x t U n i c o d e 函数能够帮助进行这种区分:

DWORD IsTextUnicode(CONST PVOID pvBuffer, int cb,PINT pResult);

抱歉!评论已关闭.