Page 1 of 1
Output of umlaute chars at the console? Auto-set flag "/U" ?
Posted: 09 Mar 2012 03:38
by pstein
When I output/echo some text with special chars like german Umlaute or french accents at the console then the chars are not written correctly onto the console.
Writing them into a file works with the command:
chcp 1252
...but this does not help for console.
Is there a similar command here as well?
I found the command line switch
cmd.exe /U
but that means I have to call at first an initail base cmd.exe and then open another console with cmd /U.
This is unhandy.
Is there a way to ALWAYS automatically start cmd.exe with the /U flag?
No, I don't want to use shortcuts to cmd.exe.
This does not help when I start *.bat batch files.
I guess I have to fix this in Registry: But how?
Any other work around for 64bit AND 32bit Win7?
Is there a disadvantage when using always /U flag?
Thank you
Peter
Re: Output of umlaute chars at the console? Auto-set flag "/
Posted: 09 Mar 2012 11:04
by Liviu
pstein wrote:When I output/echo some text with special chars like german Umlaute or french accents at the console then the chars are not written correctly onto the console.
Writing them into a file works with the command:
chcp 1252
...but this does not help for console.
You don't give enough details to tell for sure, but most likely all you need is to set the console to a TT font like Lucida Console instead of the default raster font.
pstein wrote:I found the command line switch
cmd.exe /U
The /u switch does not affect the output displayed in the console, just the piped or redirected output.
pstein wrote:No, I don't want to use shortcuts to cmd.exe.
This does not help when I start *.bat batch files.
I guess I have to fix this in Registry: But how?
Per-batch file console properties (including font) are remembered under HKCU_Console.
Liviu
Re: Output of umlaute chars at the console? Auto-set flag "/
Posted: 30 Mar 2012 06:38
by pstein
Liviu wrote:Per-batch file console properties (including font) are remembered under HKCU_Console.
Liviu
Thank you.
But when I go (on 64bit Win7) to
HKCU_Console
as you suggested then ethere are NO specialized properties for any batch file
(although I dozends of them).
So where else can I setup e.g. that batch file aaa.bar should have 10 rows and 50 columns (instead of the default 50 rows + 100 columns)?
Re: Output of umlaute chars at the console? Auto-set flag "/
Posted: 30 Mar 2012 08:00
by foxidrive
pstein wrote:But when I go (on 64bit Win7) to
HKCU_Console
as you suggested then ethere are NO specialized properties for any batch file
(although I dozends of them).
So where else can I setup e.g. that batch file aaa.bar should have 10 rows and 50 columns (instead of the default 50 rows + 100 columns)?
Can you search the registry for a unique batch file name? Maybe the location has changed in 64 bit windows.
Re: Output of umlaute chars at the console? Auto-set flag "/
Posted: 31 Mar 2012 07:54
by aGerman
@pstein
Your name sounds German. I assume the editor you use saves the code in code page 1252. That means if you save the Umlaut ö then it is represented as 11110110 (hex 0xF6) in the file. See
http://en.wikipedia.org/wiki/Windows-1252Cmd.exe parses the file in code page 850 with German settings. 0xF6 is now interpreted as character ÷ as you can see here:
http://en.wikipedia.org/wiki/Code_page_850The simpliest way is to save the batch file encoded in cp850 (some editors support it). Another possible way is to use variables, eg.
Code: Select all
@echo off &setlocal
setlocal&for /f "tokens=2 delims=:" %%a in ('chcp') do (set /a oemcp=%%~na&chcp 1252>nul)
for /f "tokens=1-7" %%a in ('echo Ä Ö Ü ä ö ü ß^&chcp %oemcp%^>nul') do (
set au=%%a&set ou=%%b&set uu=%%c&set al=%%d&set ol=%%e&set ul=%%f&set sz=%%g)
(endlocal&set Ä=%au%&set Ö=%ou%&set Ü=%uu%&set ä=%al%&set ö=%ol%&set ü=%ul%&set ß=%sz%)
echo German example:
echo %Ä%nderungen der Ma%ß%einheiten f%ü%hren m%ö%glicherweise zu
echo verf%ä%lschten Ergebnissen in der %Ü%bertragsgleichnung.
echo(
pause
Regards
aGerman
Re: Output of umlaute chars at the console? Auto-set flag "/
Posted: 05 Apr 2012 05:54
by pstein
aGerman wrote:@pstein
I assume the editor you use saves the code in code page 1252. That means if you save the Umlaut ö then it is represented as 11110110 (hex 0xF6) in the file. See
http://en.wikipedia.org/wiki/Windows-1252Cmd.exe parses the file in code page 850 with German settings. 0xF6 is now interpreted as character ÷ as you can see here:
The simpliest way is to save the batch file encoded in cp850 (some editors support it).
@aGerman:
Hmm, file storage is not the problem.
I am using (from batch file) a program which in turn decides to use a codepage independently of the user.
I have no choice which code page it uses.
Ok, an example: Have a look at the well know, very good, free cmdline program XXCOPY (not XCOPY) from here:
http://www.xxcopy.com/xcpydnld.htmIt reads e.g. during /CLONE or COPY operation filenames as "Änderung Überspannschutz.doc" from hard disc but displays messed filenames onto cmdprompt log output.
How can I avoid this?
Peter
Re: Output of umlaute chars at the console? Auto-set flag "/
Posted: 05 Apr 2012 06:01
by Squashman