Delphi-获取Windows的默认非Unicode字符集 [英] Delphi - Get Windows' default non-unicode character set
问题描述
我有一个Delphi 7应用程序.我需要能够为非unicode程序获取默认的Windows字符集.我知道DEFAULT_CHARSET设置了它,但是我需要确切知道它是哪个字符集,以便可以将其与其他字符集进行比较.这有可能吗?
I have a Delphi 7 application. I need to be able to get the default Windows character set for non-unicode programs. I know DEFAULT_CHARSET sets it, but I need to know exactly which charset it is, so that I could compare it to other character sets. Is this possible and how?
谢谢!
推荐答案
GetFontData调用 GetObject
并使用 LogFont.lfCharSet
确定字符集
GetFontData is calling GetObject
and using LogFont.lfCharSet
to determine the charset
使用HFONT调用的GetObject将填充 LogFont定义在这里
DEFAULT_CHARSET设置为基于当前系统的值区域设置.例如,当系统区域设置为英语(美国)时,将其设置为ANSI_CHARSET.
DEFAULT_CHARSET is set to a value based on the current system locale. For example, when the system locale is English (United States), it is set as ANSI_CHARSET.
带有CP_ACP的GetCPInfoEx 提供 CPINFOEX 结构将提供系统默认值 Windows ANSI代码页.
GetCPInfoEx with CP_ACP delivering a CPINFOEX structure will deliver the system default Windows ANSI code page.
var
CPInfoEx:TCPInfoEx;
CD:Cardinal;
CharsetInfo:TCharSetInfo;
CSN:String;
begin
If GetCPInfoEx(CP_ACP,0,CPInfoEx) then
begin
CD := CPInfoEx.Codepage;
if TranslateCharsetInfo(CD,CharsetInfo,TCI_SRCCODEPAGE) then
begin
CharsetToIdent(CharsetInfo.ciCharset,CSN);
Showmessage(CPInfoEx.CodePageName+' - '+IntToStr(CharsetInfo.ciCharset)+' - '+CSN);
end;
end;
end;
这篇关于Delphi-获取Windows的默认非Unicode字符集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!