Reputation: 55
my unicode characters aren't displaying correctly from a run batch file but they display fine in the cmd prompt
(note: you have to have set cmd to use consolas for this to work)
so i have a text file that contains
╔══════╗
║ ║
╚══════╝
and a bat file that contains
chcp 65001
@echo off
cls
type textfile.txt
pause
when i open a cmd window and type in chcp 65001
then type textfile.txt
i get
╔══════╗
║ ║
╚══════╝
but if i try to run the bat file all i get is
´╗┐ÔòöÔòÉÔòÉÔòÉÔòÉÔòÉÔòÉÔòù
Ôòæ Ôòæ
ÔòÜÔòÉÔòÉÔòÉÔòÉÔòÉÔòÉÔòØ
which is what normally happens if i dont use chcp.. for some reason when run from a bat file the type command isn't using the type page?
Upvotes: 1
Views: 826
Reputation: 73566
It happens because your batch file is saved in UTF8 encoding with a standard 3-byte BOM (Byte Order Mark) at the beginning. These characters aren't recognized by CMD interpreter, it sees them as a part of the first line and naturally can't execute ???chcp
.
Upvotes: 2