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)

  • Note the purposed solution could break Windows' find.exe (which would cause problems with Android SDK build): superuser.com/questions/176737/… – J Rao Jan 18 '15 at 5:24
  • Hm, when I use chcp 65001 my console windows crash when I do dir, but it helps to simply start cmd.exe with the /u flag (nb: it does use unicode by it is not reflected in chcp.com output) – eckes Jan 27 '15 at 18:58
  • Using the UTF-8 code-page also breaks the more command (it gives the misleading error message Not enough memory.) Opening the command-prompt with the /U switch does not help. – Synetech Mar 7 '16 at 22:00
  • 8
    The Windows console is riddled with bugs when the encoding is set to an unsupported multi-byte code page like 65001. Any software using the output counts of the Win32 WriteFile/ReadFile APIs will get the wrong results and consequently stuff build on that like the MSVCRT's implementation of the stdlib will produce mangled/repeated output and hang on input when confronted with non-ASCII. Until MS get around to fixing it — and it has been decades with no sign of that happening — globally changing console code page to 65001 is an extraordinarily bad idea. – bobince Oct 14 '16 at 8:51
  • 1
    Any use of the A versions of Windows functions is broken. All code needs to be ported to use the W versions. – Demi Apr 7 '17 at 14:42
up vote 82 down vote accepted

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
  • 11
    Be aware that changing the codepage will not only affect the console though. To make it only apply to the console, you could put chcp 65001 into the HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun. – Nils Magne Lunde Apr 12 '11 at 12:54
  • 4
    Surprisingly changing the OEMCP registry setting made my system unable to boot so I had to use system recovery to restore to working state. Autorun did the trick, however. – Regent Apr 12 '11 at 13:35
  • 6
    @Regent: If this solution makes your system unbootable, why did you mark it as accepted, then? – Tim Pietzcker Sep 19 '12 at 14:25
  • 7
    @galacticninja simply putting chcp 65001 will cause every opened command prompt to print 'Active code page: 65001' whilst @chcp 65001>nul will prevent any output. – Regent Mar 26 '15 at 15:51
  • 6
    Autorun is not present for me under Windows 8.1. – kleinfreund May 10 '15 at 9:09

I don't like change the system. This creates a lot of problems for me. I created a batch file:

@ECHO OFF
REM change CHCP to UTF-8
CHCP 65001
CLS

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

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

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

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

  • 6
    Note that it will print Active code page: 65001 to stdout. So if you are doing something like CHCP 65001 && mycommand.exe then you'll get the codepage printed out at the start. You need to CHCP 65001 >nul && mycommand.exe – frumbert Jun 12 '15 at 5:33

Reg file:

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe]
"CodePage"=dword:fde9
  1. Value must be in hex
  2. Top line must be included exactly as is
  3. HKEY_CURRENT_USER cannot be abbreviated
  4. dword cannot be omitted

Command Prompt:

REG ADD HKCU\Console\%SystemRoot^%_system32_cmd.exe /v CodePage /t REG_DWORD /d 65001
  1. Value can be in dec or hex
  2. %SystemRoot% must be escaped
  3. REG_DWORD cannot be omitted

PowerShell:

New-Item -ErrorAction Ignore HKCU:\Console\%SystemRoot%_system32_cmd.exe
Set-ItemProperty HKCU:\Console\%SystemRoot%_system32_cmd.exe CodePage 65001
  1. Value can be in dec or hex
  2. -Type DWord is assumed with PowerShell 3+
  3. Can use ni -> New-Item
  4. Can use sp -> Set-ItemProperty
  5. Can use -ea 0 -> -ErrorAction Ignore

Cygwin:

regtool add '\HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe'
regtool set '\HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe\CodePage' 65001
  1. Value can be in dec or hex
  2. Can use / -> \
  3. Can use HKCU -> HKEY_CURRENT_USER
  4. Can use user -> HKEY_CURRENT_USER

The command to change the codepage is chcp <codepage>. 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.

  • This one worked perfectly for me. -NoExit -Command "chcp 1252 > null" also omits the message about the selected code page in the beginning. – CodeMonkey Aug 3 at 8:53

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

PS> Set-ExecutionPolicy RemoteSigned
PS> New-Item -Path $Profile -ItemType file -Force
PS> notepad $Profile

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.

  • 1
    @PimpJuiceIT, no.. see the first line of this answer. – Dacto 2 days ago

protected by Community Feb 24 '17 at 18:28

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.