Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Windows' command prompt : How to DEFINITELY change default codepage (See related posts)

Want to use WinLatin1 (1252) instead of DOSLatin1 (850, default when cmd.exe is started) ?

You want to apply the new codepage to :
- the current opened command prompt
C:\> chcp 1252

- all the opened command prompt in the future
Start->Run->regedit
Go to [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage]
And change the "OEMCP" value to "1252"

You need to restart your computer to see the changes.

So you'll be able to display extended characters (such as accents and so on)

==

Don't know how to check the command prompt's codepage ?
C:\> chcp


==

Want to see the result in practice ?
Edit a codepage.txt file and type "à la bonne heure, ça marche ! (peut être)", then open a command prompt and check this out :
C:\> type codepage.txt


Comments on this post

p_ posts on Apr 12, 2007 at 10:44
Change the code page in your registry and you may not be able to reboot your windows anymore.
I tried to change it to 65001, to make windows save filenames with utf8 encoding, which it didn't like at all.
Resolved by rechanging the value with an offline registry editor (http://home.eunet.no/pnordahl/ntpasswd/)
neologfr posts on Jul 09, 2007 at 19:24
Thanks for this comment.
I have never had any problem with this codepage (I do this change on every new pc I use : home, work, etc...)
gpvos posts on Apr 14, 2008 at 14:03
There is a difference between "table-based" and "non-table-based" codepages in MS-Windows. The value for OEMCP must be a non-table-based codepage. "chcp 65001" seems to work for UTF-8, although I remember having problems with it in the past (could be an earlier version of MS-Windows, though).

Another way could be to put "chcp 1252" into "HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun" (REG_SZ). You'll get an annoying "Active code page: 1252" at the top of every command line window, though, and it only works for console windows in which you run cmd.exe .
gpvos posts on Apr 14, 2008 at 14:04
Should be table-based, of course.
gpvos posts on Apr 15, 2008 at 10:36
Note that this changes more than just the console code page. After making this change, you can enter character codes in Windows by using for example Alt-232 instead of Alt-0232.

You need to create an account or log in to post comments to this site.