CHCP.com

Change the active console OEM Code Page. A code page is a set of character codes and their corresponding characters. The default code page is determined by the Windows Locale.

Syntax
      CHCP [code_page]

Key
   code_page  A code page number (e.g. 437)  

When working with characters outside the ASCII range of 0-127, such as some box characters, the choice of code page will determine the set of characters displayed.

A given system has two active code pages, which are both set via: Control Panel ➞ Region ➞ Administrative ➞ Language for non-Unicode programs

Changes made to the OEM code page with chcp will remain for the current session only. They will be inherited by any sub-session i.e opening a new CMD.exe process within the current one.

Programs that you start within the session, after you assign a new code page will use the new code page, however, programs (except Cmd.exe itself) that you started before assigning the new code page will use the original code page.

In Europe where characters such as Umlaut [ü] are common and used in the file system, setting your batch files to use a matching character set can improve handling of those characters (in Notepad++ [Menu] ➞ Encode ➞ Character set) [x]

Code page Country/ Region/ Language  
437 United States default code page in the US
850 Multilingual (Latin I) default code page in most of Europe
852 Slavic (Latin II)  
855 Cyrillic (Russian)  
857 Turkish  
860 Portuguese  
861 Icelandic  
863 Canadian-French  
865 Nordic  
866 Russian  
869 Modern Greek  
1252 West European Latin  
65000 UTF-7 *  
65001 UTF-8 *  

* The 65000/1 code pages are encoded as UTF-7/8 to allow to working with unicode data in 7-bit and 8-bit environments.
Full list of code page identifiers at Microsoft.com.

Registry Keys:

HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage
HKLM:\SYSTEM\CurrentControlSet\Control\Nls\Language

Unicode issues

Although chcp does allow selecting Unicode, the support for Unicode within CMD is still very limited, e.g. The commands More and Find will not work properly. To work with Unicode it is MUCH easier to just use PowerShell.

If you use CHCP to run the Windows Console in a unicode code page, many applications will assume that the default Windows code page still applies, e.g. Java requires the-Dfile option: java -Dfile.encoding=UTF-8

Unicode characters will only display if the current console font contains the characters. So use a TrueType font like Lucida Console instead of the CMD default Raster Font.

The CMD Shell (which runs inside the Windows Console)

CMD.exe only supports two character encodings Ascii and Unicode (CMD /A and CMD /U)

If you need full unicode support use VERY limited support for unicode in the CMD shell, piping, redirection and most commands are still ANSI only. The only commands that work are DIR, FOR /F and TYPE, this allows reading and writing (UTF-16LE / BOM) files and filenames but not much else.

Code Pages

For a full list of code pages supported on your machine, run NLSINFO (Resource Kit Tools). Old versions of Windows had a more limited set available.

Files saved in Windows Notepad will be in Unicode UTF-8 No BOM by default, (ANSI format prior to W10 1903).
Unicode files  that include a BOM will make a batch file not executable on Windows.
Other encodings like CP 850 require a third party text editor.

Examples

View the current code page, in some locales the output will include a trailing period:

C:\> chcp
850.

Save the current code page to the variable %_codepage%.

For /f "tokens=2 delims=:." %%G in ('chcp') Do set _codepage=%%G

Change the code page to Unicode/65001:

chcp 65001

Restore the original code page:

chcp %_codepage%

“Remember that there is no code faster than no code” ~ Taligent’s Guide to Designing Programs

Related commands

MODE CON CP SELECT= - Select a Code Page.
[Undocumented] CHCP - Forum.
Transcoding to ANSI with CHCP - Forum.
Full list of Code Page Identifiers - docs.microsoft.com
Locale names.
TYPE - can print UTF-16LE files with a BOM regardless of the current codepage.
What every software developer must know about Unicode and Character Sets ~ Joel Spolsky.
Equivalent PowerShell: Get-WinSystemLocale / [Console]::OutputEncoding - convert text to Unicode.
Equivalent bash command (Linux): LANG - locale category environment variable & LC_* variables for locale category.


 
Copyright © 1999-2025 SS64.com
Some rights reserved