Change CodePage in CMD permanently?
My Windows cmd CodePage is now under 65001. Since I was d开发者_运维知识库oing 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?
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.)
Here I found a better solution:
- Start -> Run -> regedit
- Go to [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
- Add new String Value named: Autorun
- 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.
http://technet.microsoft.com/en-us/library/cc779439%28WS.10%29.aspx
c:\startup.cmd
@echo off
chcp 437
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.
Setting the default CMD/shell Codepage can be neatly done using the following command:
REG ADD HKCU\Console\%SystemRoot^%_system32_cmd.exe /v CodePage /t REG_DWORD /d 437
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).
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage
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.
精彩评论