如何获取windows xp gui默认代码页? [英] How to get windows xp gui default code page?

查看:199
本文介绍了如何获取windows xp gui默认代码页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是非英语版本的XP代码页的控制台和gui应用程序不同,例如,如果我在波兰语版本写在控制台:

  echozażółćgęśląjaźń> somefile.txt 

该文件的内容为:

 zaľ˘†g©lĄja«ä

这不会发生,如果我把它放入cmd文件。这是这个文本用波兰字母。但是如果我创建一个使用非英语字符命名的文件或目录,那么无论是从cmd还是从手指运行,效果总是乱码。



我的问题是如何获得这个第二个代码页,其余的Windows正在运行。在我的例子中,这个CP是1250 - 但是如何从c ++获取这个数字?



GetConsoleCP() code> GetConsoleOutputCP()都返回852(这是正确的)和 GetThreadLocale()给出1045。



如果我尝试 chcp 1045 ,它会提供错误的代码页。

解决方案

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP - 此注册表项存储ANSI代码页码(在您的情况下应为1250)和 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\OEMCP 存储OEM代码页。 / p>

哦,还有 GetACP GetOEMCP 功能。


The thing is that on non-english versions of XP code pages for console and gui apps differ, for example if I on my Polish version write in console:

echo zażółć gęślą jaźń > somefile.txt

The content of that file is:

zaľ˘† g©lĄ ja«ä 

This isn't happening if I put that into cmd file. That is this text with polish letters. But if I create a file or directory that is named using non English only chars, then no matter if it's run from cmd or from finger the effect is always gibberish.

So my question is how to get this second code page that rest of windows is running with. In my case this CP is 1250 - but how to get this number from c++ ?

GetConsoleCP() and GetConsoleOutputCP() both return 852 (which is correct) and GetThreadLocale() gives 1045.

If I try to chcp 1045 it gives "wrong code page".

解决方案

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP - this registry key stores the ANSI code page number (it should be 1250 in your case) and HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\OEMCP stores OEM code page.

Oh, and there are GetACP and GetOEMCP functions.

这篇关于如何获取windows xp gui默认代码页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆