Char/String Compare
Posted: 02 Oct 2013 11:39
Hi,
How work the IF with char ?
Result:
Einstein1969
How work the IF with char ?
Code: Select all
@echo off & setlocal EnableDelayedExpansion
chcp 850
call :test
chcp 437
call :test
goto :eof
:test
call :check "A" "A"
call :check "A" "B"
call :check "A" "a"
call :check "A" "b"
call :check "A" "í"
call :check "A" "î"
call :check "A" "~"
call :check "A" "€"
goto :eof
:check s1 s2
set "s1=%~1"
set "s2=%~2"
if !s1! gtr !s2! (echo "!s1!" gtr "!s2!"
) else if !s1! lss !s2! (echo "!s1!" lss "!s2!"
) else if !s1! equ !s2! (echo "!s1!" = "!s2!"
) else (echo ?)
goto :eof
Result:
Code: Select all
E:\x264\provini>tmp2
Tabella codici attiva: 850
"A" = "A"
"A" lss "B"
"A" gtr "a"
"A" lss "b"
"A" lss "Ý"
"A" gtr "¯"
"A" gtr "~"
"A" lss "Ç"
Tabella codici attiva: 437
"A" = "A"
"A" lss "B"
"A" gtr "a"
"A" lss "b"
"A" lss "φ"
"A" lss "ε"
"A" gtr "~"
"A" lss "Ç"
Einstein1969