ansi编码与unicode有什么联系吗?如果有我该如何转换呢?

来源:百度知道 编辑:UC知道 时间:2024/06/08 11:00:36
ansi编码与unicode有什么联系吗?如果有我该如何转换呢?例如:在Unicode中,汉字“中”对应的数字是20013(二进制100111000101101) 而ansi编码为[0xD6,0xD0],他们是如何转过来的? 哪位知道的指导下啊?谢谢

可以使用windows的函数MultiByteToWideChar,WideCharToMultiByte做相互转换.
下面是关于这两个函数的说明.

如果使用delphi编个程序转换,可以使用StringToWideChar和WideCharToString两个函数实现.

The MultiByteToWideChar function maps a character string to a wide-character (Unicode) string. The character string mapped by this function is not necessarily from a multibyte character set.

int MultiByteToWideChar(

UINT CodePage, // code page
DWORD dwFlags, // character-type options
LPCSTR lpMultiByteStr, // address of string to map
int cchMultiByte, // number of characters in string
LPWSTR lpWideCharStr, // address of wide-character buffer
int cchWideChar // size of buffer
);

The WideCharToMultiByte function maps a wide-character string to a new character string. The new character string is not necessarily from a multibyte character set.

int WideCharToMultiByte(

UINT CodePage, // code page