A code page is a character set encoding alias, also known as an "Inner code table ", which is a table for a specific language's character set.
There are two types of code pages: one is the ANSI code page, and the other is the OEM code page.
The ⑴OEM code page is primarily used for command line interface (Console) programs in Windows systems, virtual Dos.
The⑵ ANSI code page is primarily used for graphical user interface (Gui) programs that are not Unicode -encoded locally in Windows systems.
Procedure Tform9.bitbtn3click (Sender:tobject);
Var
Cpinfoex:tcpinfoex;
Begin
//GETACP: gets the ANSI code page for the current system ;
// specific can control : start è program è run,CMDè input CHCP;
Windows.getcpinfoex (WINDOWS.GETACP,0,CPINFOEX);
MEMO2.LINES.ADD (Sysutils.format (' ANSI Code page:%s ', [Cpinfoex.codepagename]));
//GETOEMCP: gets the OEM code page for the current system ;
Windows.getcpinfoex (WINDOWS.GETOEMCP,0,CPINFOEX);
MEMO2.LINES.ADD (Sysutils.format (' OEM Code page:%s ', [Cpinfoex.codepagename]));
// conclusion : for the Chinese operating system , the ANSI code page and the OEM code page are 936 (ansi/oem- Simplified Chinese GBK);
End
The Windows API function GETACP can get code page encoding for the current system, such as 936 in Simplified Chinese.
If you want to get a code page under Dos, you need to call the GETOEMCP function.
If you want to determine the validity of the code page, call the IsValidCodePage function.
The above functions need to refer to the Windows unit in Delphi.
Figures: