加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

winapi – 如何以编程方式确定Windows的当前默认代码页?

发布时间:2020-12-14 04:19:14 所属栏目:Windows 来源:网络整理
导读:我必须将VB6应用程序的字符串输出的编码转换为特定的编码. 问题是,我不知道字符串的编码,因为: According to the VB6 documentation when accessing certain API functions the internal Unicode strings are converted to ANSI strings using the default
我必须将VB6应用程序的字符串输出的编码转换为特定的编码.

问题是,我不知道字符串的编码,因为:

According to the VB6 documentation when accessing certain API functions the internal Unicode strings are converted to ANSI strings using the default codepage of Windows.

因此,字符串输出的编码在不同系统上可能不同,但我必须知道它才能执行转换.

如何使用Win32 API读取默认代码页,或者 – 如果没有其他方法 – 通过阅读注册表?

通过使用 GetACP – Win32 API调用返回默认代码页,它可能更简洁! (默认代码页通常称为“ANSI”)
int nCodePage = GetACP();

此外,许多API调用(例如MultiByteToWideChar)接受始终为means “use the system code page”的常量值CP_ACP(零).因此,您可能实际上不需要知道当前代码页,具体取决于您要对其执行的操作.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读