Delphi - 获取Windows的默认非unicode字符集

标签 delphi character-encoding non-unicode

我有一个 Delphi 7 应用程序。我需要能够获取非 unicode 程序的默认 Windows 字符集。我知道 DEFAULT_CHARSET 设置了它,但我需要确切地知道它是什么字符集,以便我可以将它与其他字符集进行比较。这可能吗?如何实现?

谢谢!

最佳答案

GetFontData 正在调用 GetObject 并使用 LogFont.lfCharSet 来确定字符集

GetObject called with HFONT将填充LogFont 这里的定义是

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.

GetCPInfoEx with CP_ACP交付 CPINFOEX结构将提供系统默认Windows ANSI 代码页。

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字符集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15729116/

相关文章:

delphi - 使用什么 Indy FTP 事件来检测连接正常关闭

php - 妥善解决

c++ - libc++ 与 VC++ : Can non-UTF conversions be done with wstring_convert?

java - 附加到 JTextArea 不会在 '\n' 上创建换行符

unicode - 何时使用 Unicode(除了非 unicode!)

delphi - Indy TCP 客户端/服务器,客户端充当服务器

delphi - 如何声明包含使用记录作为参数的事件的记录

delphi - 具有指定值的枚举类型没有TypeInfo,为什么?

python - 解码 Unicode 字符串;这是什么意思,我该如何避免呢?