I have a problem when executing a "type" command on a file that containg regional characters. Although i can see the file properly with notepad or any other editor, when i try the command "type file" from the command line the regional characters are shown incorrectly.
I've tried executing chcp 850 or chcp 1250 but doesn't work. Executing cmd.exe /u doesn't work either.
Can u help me please?
Thanks
Best Answer
Code page
You should set the code page used in the `chcp' command should match the encoding used in the file.
If Notepad recognises the file, it must be in one of the encodings that Notepad recognises:
ANSI .................
Usually Windows Latin-1, code page 1252.Unicode ..............
UTF-16 Little Endian with Byte Order Mark (BOM).Unicode Big-endian ...
UTF-16 big-endian with BOM.UTF-8.................
UTF-8 with BOM.So, if the file was encoded in UTF-8 Unicode, you could use
chcp 65001
As barlop commented below: "UTF-16 code pages are not supported in Command Prompt windows." Therefore in order to display data from UTF-16 files, the best you can do is probably to convert such files to UTF-8 using either Notepad or another suitable tool (perhaps iconv or recode).
Font
You should also set the font of the Command Prompt window to a font containing the particular characters you need to display. For example Lucida Console, if appropriate. You can do this from the context menu (right mouse button click) on the title-bar of the window, select the "Properties" option.
If you have a monospaced font whose character set includes the specific characters you need, you can adapt these instructions to make the command prompt window use that font.
Example
See also
See related question https://stackoverflow.com/questions/4572393/perl-unicode-glitch