Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi - Get Windows' default non-unicode character set

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?

Thanks!

like image 944
jedivader Avatar asked May 17 '26 09:05

jedivader


1 Answers

GetFontData is calling GetObject and using LogFont.lfCharSet to determine the charset

GetObject called with HFONT will fill LogFont Definition here is

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 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;
like image 171
bummi Avatar answered May 20 '26 05:05

bummi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!