IBM Support

 How to change the codepage for DOS batch files to ANSI

Question & Answer


Question

 How to change the codepage for DOS batch files to ANSI

Answer

The Windows command interpreter (CMD.exe) and thus any DOS batch file use a different codepage (437) than other Windows applications, like Notepad or the CD Command Line Interface (Direct.exe). This may cause issues with special characters.

For example when your batch file generates an input file for your Windows application from a directory listing. Any file name containing a special character, like a German umlaut, will not show up correctly in your Windows application and likely cause it to fail.

The solution is to change the codepage at the beginning of your batch file using the CHCP command.
To change the codepage to 1252 (ANSI - Latin I), type:

CHCP 1252

For more information on the CHCP command, type:

CHCP /?

[{"Product":{"code":"SSRRVY","label":"IBM Sterling Connect:Direct for Microsoft Windows"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Not Applicable","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All","Edition":"","Line of Business":{"code":"LOB02","label":"AI Applications"}}]

Historical Number

HTG1152

Document Information

Modified date:
24 July 2020

UID

swg21562473