描述
将Unicode字节转换为ANSI字节.
FreeBASIC 语法
FUNCTION AfxAcode ( _ BYVAL pwszStr AS WSTRING PTR, _ BYVAL nCodePage AS LONG = 0 _ ) AS STRING |
FUNCTION AfxAcodeB ( _ BYVAL pwszStr AS AFX_BSTR, _ BYVAL nCodePage AS LONG = 0 _ ) AS STRING |
FUNCTION AfxAcodeV ( _ BYVAL pvarIn AS VARIANT, _ BYVAL nCodePage AS LONG = 0 _ ) AS STRING |
参数
pwszStr |
[in]的WSTRING或AFX_BSTR转换. |
nCodePage |
[in, opt]转换中使用的代码页,如1251俄罗斯.如果你指定CP_UTF8,返回的字符串将UTF8编码.如果你不通过Unicode页面,该函数将使用CP_ACP (0),这是系统默认的Windows ANSI代码页. |
返回值
ANSI或UTF8编码的字符串.
用法示例 (Russian BSTR string to ANSI string):
DIM bs AS AFX_BSTR
bs = AfxUcode(CHR(209, 229, 236, 229, 237), 1251)
MessageBoxW 0, bs, "", MB_OK
DIM s AS STRING
s = AfxAcode(bs, 1251)
MessageBoxW 0, s, "", MB_OK
IF bs THEN SysFreeString(bs)
用法示例 (Russian BSTR string to Russian UTF8 string)
DIM bs AS AFX_BSTR
bs = AfxUcode("ДмиÌтрий ДмиÌтриевич", CP_UTF8)
MessageBoxW 0, bs, "", MB_OK
DIM s AS STRING
s = AfxAcode(bs, CP_UTF8)
MessageBoxW 0, s, "", MB_OK
IF bs THEN SysFreeString(bs)
用法示例 (Russian WSTRING to ANSI string)
DIM wszText AS WSTRING * 260
AfxUcode(CHR(209, 229, 236, 229, 237), @wszText, SIZEOF(wszText), 1251)
MessageBoxW 0, wszText, "", MB_OK
DIM s AS STRING
s = AfxAcode(@wszText, 1251)
MessageBoxW 0, s, "", MB_OK
用法示例 (Russian WSTRING to UTF8 string)
DIM wszText AS WSTRING * 260
AfxUcode("ДмиÌтрий ДмиÌтриевич", @wszText, SIZEOF(wszText), CP_UTF8)
MessageBoxW 0, wszText, "", MB_OK
DIM s AS STRING
s = AfxAcode(@wszText, CP_UTF8)
MessageBoxW 0, s, "", MB_OK
引用文件
AfxStr.inc