CHCP – DOS Special Character Problems (CMD Active Codes)


Another “very hard to find” tip… When writing batch files with some special characters like “é” or “à”, you might have surprise errors. Running batch files, with special characters in the code, can cause some serious interpretation problems and your commands might not work at all. Sometimes, you can’t avoid using these characters, like in my case. Because I live in Montréal, Québec (French part of Canada) and there are serious law issues that we have to respect and I think the most difficult part of my job is this language issue.

The trick is hidden in this link from Microsoft;



The « chcp » command displays or sets the active code page number is the remedy to your problem. By putting the “chcp 1252” at the beginning of your code, you are changing the “active code” for your cmd environment before even executing your commands in the batch file. The number 1252 is the code for West European Latin characters which in my case resolves the "é" - "à" - "è" type of characters. For other regional codes, please refer to the previous link or the table below;
Code page
Country/region or language
437
United States
850
Multilingual (Latin I)
852
Slavic (Latin II)
855
Cyrillic (Russian)
857
Turkish
860
Portuguese
861
Icelandic
863
Canadian-French
865
Nordic
866
Russian
869
Modern Greek


Optionally, if you want further info on the "Dos Code Pages", visit WikiPedia's site for that as it's the best resources that I could find.


Comments

Popular posts from this blog

System.Messaging.MessageQueueException (0x80004005): A workgroup installation computer does not support the operation (Public Queue create issue)

Veeam Backup Error : Failed to prepare guest for hot backup. Error: VSSControl

warning: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead - Chef Development Kit Update