[note] using the API function GETACP get the Windows System current code page

Source: Internet
Author: User

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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.