Output of umlaute chars at the console? Auto-set flag "/U" ?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
pstein
Posts: 125
Joined: 09 Nov 2011 01:42

Output of umlaute chars at the console? Auto-set flag "/U" ?

#1 Post by pstein » 09 Mar 2012 03:38

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

Liviu
Expert
Posts: 470
Joined: 13 Jan 2012 21:24

Re: Output of umlaute chars at the console? Auto-set flag "/

#2 Post by Liviu » 09 Mar 2012 11:04

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

pstein
Posts: 125
Joined: 09 Nov 2011 01:42

Re: Output of umlaute chars at the console? Auto-set flag "/

#3 Post by pstein » 30 Mar 2012 06:38

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)?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Output of umlaute chars at the console? Auto-set flag "/

#4 Post by foxidrive » 30 Mar 2012 08:00

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.

aGerman
Expert
Posts: 4740
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Output of umlaute chars at the console? Auto-set flag "/

#5 Post by aGerman » 31 Mar 2012 07:54

@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-1252
Cmd.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_850

The 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

pstein
Posts: 125
Joined: 09 Nov 2011 01:42

Re: Output of umlaute chars at the console? Auto-set flag "/

#6 Post by pstein » 05 Apr 2012 05:54

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-1252
Cmd.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.htm

It 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


Post Reply