The following code need a
parameter (name of city) to check this in in file. Don't use quotes in the parameter.
BATCH
SaarbrückenBATCH
Frankfurt (Main)Code: Select all
@echo off
setlocal EnableExtensions
REM in Windows found the German characters in CP1252 and CP1250 at the same position
REM check: input Alt+0165 in your editor, when you see the Yen sign is this CP1252
REM ECHO "ä" "ö" "ü" "Ä" "Ö" "Ü" "ß" CP1252
REM ECHO "„" "”" "" "Ž" "™" "š" "á" CP850
REM ECHO "ae" "oe" "ue" "Ae" "Oe" "Ue" "ss" alternate input
if "%1" EQU "" (echo no parameter) & goto :eof
set sstr=%*
set wstr=%*
rem convert WSTR <==> word string (input / output to file) - Alt+xxx (CP850) = Windows charcter (CP1252)
rem rows sort: ae, oe, ue, Ae, Oe, Ue, ss
set wstr=%wstr:„=ä%
set wstr=%wstr:”=ö%
set wstr=%wstr:=ü%
set wstr=%wstr:Ž=Ä%
set wstr=%wstr:™=Ö%
set wstr=%wstr:š=Ü%
set wstr=%wstr:á=ß%
rem convert SSTR <==> search string (regular expression) - Alt+xxx (CP850) = Windows charcter (CP1252)
rem character Ae, Ue, ss and space convert to "." (dot)
rem rows sort: ae, oe, ue, Ae, Oe, Ue, ss, space
set sstr=%sstr:„=ä%
set sstr=%sstr:”=ö%
set sstr=%sstr:=ü%
set sstr=%sstr:Ž=.%
set sstr=%sstr:™=Ö%
set sstr=%sstr:š=.%
set sstr=%sstr:á=.%
set sstr=%sstr: =.%
echo "%wstr%" -- "%sstr%"
echo.
set found=NO
for /f "tokens=*" %%a in ('findstr /i /r "%sstr%" UmlauteStadt.txt') do if "%%a" EQU "%wstr%" set found=YES
if %found% EQU NO echo %wstr%>>UmlauteStadt.txt
In the 5th row are the characters from CP1252 from left to right:
0xE4 0xF6 0xFC 0xC4 0xD6 0xDC 0xDF
Alt+0228 Alt+0246 Alt+0252 Alt+0196 Alt+0214 Alt+0220 Alt+0223 - input in the file
The charcters in the 6th row in the same order, but characters from CP850 that are writing from the promt to the file.
Alt+0132 Alt+0148 Alt+0129 Alt+0142 Alt+0142 Alt+0154 Alt+0225 - input in the file; Alt+0129 not possible
Input from prompt: ECHO
"ä" "ö" "ü" "Ä" "Ö" "Ü" "ß" CP850 >>file
In the file you will find all seven charcters between the quotes.
In the 7th row is a alternate from this characters, when is not possible to write the correct charcters.
To convert the WSTR: set wstr=%wstr:
„=
ä%
To convert the SSTR the same commands but not for all characters. There are four characters that change to "." (dot).
The last character in this block to converts is the space character.
FINDSTR can not used the graphical characters like lines and blocks.
The space character seperated the search string in more search strings.
Example: search "
Bad Kleinen" -- find: "
Bad Salzungen" or "
Baden-
Baden"
The "." (dot) ist representing one character in the regular expression.