Change cmd locale windows

chcp chcp

Изменяет активную кодовую страницу консоли. Changes the active console code page. Если используется без параметров, параметр chcp отображает номер активной кодовой страницы консоли. If used without parameters, chcp displays the number of the active console code page.

Синтаксис Syntax

Параметры Parameters

Параметр Parameter Описание Description
Задает кодовую страницу. Specifies the code page.
/? /? Отображение справки в командной строке. Displays help at the command prompt.

В следующей таблице перечислены поддерживаемые кодовые страницы и их страны, регионы или языки. The following table lists each supported code page and its country/region or language:

Кодовая страница Code page Страна, регион или язык Country/region or language
437 437 США United States
850 850 Многоязычная (латиница I) Multilingual (Latin I)
852 852 Славянские (латиница II) Slavic (Latin II)
855 855 Кириллица (Русский) Cyrillic (Russian)
857 857 Турецкий Turkish
860 860 Португальский Portuguese
861 861 Исландский Icelandic
863 863 Canadian-French Canadian-French
865 865 Скандинавская Nordic
866 866 русском языке Russian
869 869 Современный греческий Modern Greek
936 936 Китайский Chinese

Комментарии Remarks

В окне командной строки, использующем растровые шрифты, правильно отображается только кодовая страница изготовителя оборудования (OEM), установленная вместе с Windows. Only the original equipment manufacturer (OEM) code page that is installed with Windows appears correctly in a Command Prompt window that uses Raster fonts. Другие кодовые страницы отображаются правильно в полноэкранном режиме или в окнах командной строки, в которых используются шрифты TrueType. Other code pages appear correctly in full-screen mode or in Command Prompt windows that use TrueType fonts.

Вам не нужно подготавливать кодовые страницы (как в MS-DOS). You don’t need to prepare code pages (as in MS-DOS).

Программы, запускаемые после назначения новой кодовой страницы, используют новую кодовую страницу. Programs that you start after you assign a new code page use the new code page. Однако программы (кроме Cmd.exe), которые вы начали перед назначением новой кодовой страницы, продолжат использовать исходную кодовую страницу. However, programs (except Cmd.exe) that you started before assigning the new code page will continue to use the original code page.

Примеры Examples

Чтобы просмотреть текущую настройку кодовой страницы, введите: To view the active code page setting, type:

Появится сообщение следующего вида: Active code page: 437 A message similar to the following appears: Active code page: 437

Чтобы изменить активную кодовую страницу на 850 (многоязычный), введите: To change the active code page to 850 (Multilingual), type:

Если указанная кодовая страница является недопустимой, появляется следующее сообщение об ошибке: Invalid code page If the specified code page is invalid, the following error message appears: Invalid code page

CHCP.com

Change the active console Code Page. The default code page is determined by the Windows Locale.

This command is rarely required as most GUI programs and PowerShell now support Unicode. When working with characters outside the ASCII range of 0-127, the choice of code page will determine the set of characters displayed.

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

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, however

Even if you use CHCP to run the Windows Console in a unicode code page, many applications will assume that the default 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 PowerShell. There is still 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

The number of supported code pages was greatly increased in Windows 7.
For a full list of code pages supported on your machine, run NLSINFO (Resource Kit Tools).

Files saved in Windows Notepad will be in ANSI format by default, but can also be saved as Unicode UTF-16LE or UTF -8 and for unicode files, will include a BOM.
A BOM will make a batch file not executable on Windows, so batch files must be saved as ANSI, not Unicode.

View the current code page:
chcp

Change the code page to Unicode/65001:
chcp 65001

“Remember that there is no code faster than no code”

Taligent’s Guide to Designing Programs

Joel Spolsky.
Powershell: All text input is automatically converted to Unicode.
Equivalent bash command (Linux): LANG — locale category environment variable & LC_* variables for locale category.

How to get system locale in Windows 7 cmd?

How can I get system locale in Windows 7?

I mean something like: cs_CZ.UTF-8

I tried writing «locale» in the command line but that doesn’t work in Windows. Any suggestions?

5 Answers 5

There’s not a specific command (or at least, not one that I’m aware of) to get this information, but you can find it between those provided by systeminfo.exe .

Get-UICulture or Get-Host in PowerShell

If you need the actual locale to conditionally do other things in a batch file you can create a batch file (save a text file as .bat extension) with the following. As a starting point this will print to the command prompt, for example, «en-us» (no quotes) You can also use the variable !VERBOSE_SYSTEM_LOCALE! for the human readable locale e.g. English(UnitedStates)

In fact, your proposals fail, because they rely on searching a string («System Locale«) which changes depending on the current locale! On my french Win10Pro, the string is «Option régionale du système» (with accented letter, which is very difficult to handle properly in a CMD file).

I’ve done some testing, and it seems, on MY system, that the lines about locale in systeminfo output are the only ones to contain a semi-colon character («;»):

Based on that (which may NOT be true on other systems with different languages), I coded this get_locale.cmd script :

The result of my script on MY system is:

Be warned, however, that the three environment variables exist only inside the script, they do NOT persist in CMD environment after the script ends (no export command as in *nix).

Change CodePage in CMD permanently?

My Windows cmd CodePage is now under 65001. Since I was doing some Android stuff and need to use console log, but forget how changing it now.

When using chcp 437 to change the CodePage back, it works. But if I start a new cmd window, it goes back.

How to do the chcp thing to make it pernament?

6 Answers 6

Here I found a better solution:

  1. Start -> Run -> regedit
  2. Go to [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
  3. Add new String Value named: Autorun
  4. Change the value to ‘chcp 437’

Create a start up batch file that includes all the commands you want.

Then edit the registry to point to your start up file.

c:\startup.cmd

HKLM\SOFTWARE\Microsoft\Command Processor
AUTORUN=»C:\startup.cmd»

Command prompt code page always change back to the default 437 if you just use chcp 850 in cmd to change the active language code (850 = Multilingual (Latin I)). My system default language is set to English (437) although I’m Brazilian (language code 850). Once I need to show some special characters such as ã, õ, ç, I found that at Windows 10, under All Settings > Time & Language > Region & Language there is (at the top right corner) a link for Related settings — Additional date, time & regional settings. From there you’ll be redirected to Control Panel\Clock, Language, and Region. Click again on Region > Change Location and at the window Region, at the tab Administrative, change the Language for non-Unicode programs by clicking the button Change system locale and choosing some other that uses the code you need (In my case, Portuguese (Brazil) = code 850). Restart Windows and check if your command prompt is now set to the new language code (type chcp in cmd). For me, it solved the problem. There is also a Latin (Word) option on the list that I suppose is also code 850.

In the 1809 build of Windows 10 I’ve managed to permanently solve this by going to the system’s Language settings , selecting Administrative language settings , clicking Change system locale. and checking the Beta: Use Unicode UTF-8 for worldwide language support box and then restarting my pc.

This way it applies to all applications, even those ones that I don’t start from a command prompt! (Which was necessary for me, since I was trying to edit Agda code from Atom.)

Setting the default CMD/shell Codepage can be neatly done using the following command:

This will make the codepage 437 your default, but ONLY in the cmd/shell, meaning the rest of the OS is safe and the boot environment ist untouched. Instead of always changing the codepage whenever the cmd opens, the cmd will open in the specified codepage from start.

If you wish to edit it manually using regedit.exe, beware that you have to set the codepage value in ‘decimal’ (use the radio-buttons for selecting decimal or hex input).

You can edit code page value permanently by editing OEMCP key value in windows in above reg key value

Warning: Don’t do it, it will make your system unable to boot. See related.

Change default code page of Windows console to UTF-8

Currently I’m running Windows 7 x64 and usually I want all console tools to work with UTF-8 rather than with default code page 850.

Running chcp 65001 in the command prompt prior to use of any tools helps but is there any way to set is as default code page?

Update:

Changing HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\OEMCP value to 65001 appear to make the system unable to boot in my case.

Proposed change of HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun to @chcp 65001>nul served just well for my purpose. (thanks to Ole_Brun)

8 Answers 8

To change the codepage for the console only, do the following:

  1. Start -> Run -> regedit
  2. Go to [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun]
  3. Change the value to @chcp 65001>nul

If Autorun is not present, you can add a New String

Personally, I don’t like changing the registry. This can cause a lot of problems. I created a batch file:

I saved at C:\Windows\System32 as switch.bat.

I created a link for cmd.exe on the Desktop.

In the properties of the cmd shortcut, changed the destination to: C:\Windows\System32\cmd.exe /k switch

Voilá, when I need to type in UTF-8, I use this link.

Edit the Registry:

Then restart. With this fix, if you are using Consolas font, it seems to lock PowerShell into a small font size. cmd.exe still works fine. As a workaround, you can use Lucida Console, or I switched to Cascadia Mono:

In the 1809 build of Windows 10 I’ve managed to permanently solve this by going to the system’s Language settings , selecting Administrative language settings , clicking Change system locale. and checking the Beta: Use Unicode UTF-8 for worldwide language support box and then restarting my pc.

This way it applies to all applications, even those ones that I don’t start from a command prompt!
(Which was necessary for me, since I was trying to edit Agda code from Atom.)

This can be done by creating a PowerShell profile and adding the command «chcp 65001 >$null» to it:

This doesn’t require editing the registry and, unlike editing a shortcut, will work if PowerShell is started in a specific folder using the Windows Explorer context menu.

The command to change the codepage is chcp . Example: chcp 1252 . You should type it in a Powershell window. To avoid the hassle of typing it everytime (if you always have to change the codepage), you may append it to the program’s command line. To do so, follow these steps:

  1. Right-click the Powershell icon on Start menu and choose «More» > «Open file Location».
  2. Right-click the Powershell shortcut and select «Properties».
  3. Add the following to the end of the «Target» command line: -NoExit -Command «chcp 1252»

Be happy. Don’t fuss with Windows Registry unless you have no other option.

Читайте также:  Параметры уведомлений windows 10
Оцените статью