Jump to content

Recommended Posts

Posted (edited)

... obviously, I meant o = O but ó <> Ó ... :o

$a = "si"
$b = "SI"

If $a = $b Then
    MsgBox(0, $a & " / " & $b, "They're identical")
Else
    MsgBox(0, $a & " / " & $b, "They're different")
    
EndIf

$a = "sí"
$b = "SÍ"

If $a = $b Then
    MsgBox(0, $a & " / " & $b, "They're identical")
Else
        MsgBox(0, $a & " / " & $b, "They're different")
EndIf

I can't understand this. If AutoIT supports ANSI, why are special characters different depending on whether they're in lower or upper case?

My script deals with text and has to compare strings constantly, so this is a big issue for me. If I could understand how AutoIT "reads" these characters then I could figure out a solution.

Edited by Guillermo
Posted

From the help section Operators

= Tests if two values are equal (case insensitive if used with strings). e.g. If $var= 5 Then (true if $var equals 5)

== Tests if two values are equal (case sensitive if used with strings)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Posted

If you check the helpfile regarding operators you will see that both = and == can be used for testing strings - but the results may be different.

= Tests if two values are equal (case insensitive if used with strings). == Tests if two values are equal (case sensitive if used with strings)

Posted

I didn't make my point...

I've read the help file and I know the difference between "=" and "==". However, AutoIT behaves differently when testing extended characters.

melon = MELON (true)

melon == MELON (false)

but

melón = MELÓN (false)

melón == MELÓN (false)

If you try out the code I pasted in my first post you'll understand what I mean.

My question is why.

Posted (edited)

The simplest solution would be to use following:

$a = "si"
$b = "SI"

If $a = $b Then
    MsgBox(0, $a & " / " & $b, "They're identical")
Else
    MsgBox(0, $a & " / " & $b, "They're different")
    
EndIf

$a = "sí"
$b = "SÍ"
$c = StringUpper($a)
If $b = $c Then
    MsgBox(0, $a & " / " & $b, "They're identical")
Else
    MsgBox(0, $a & " / " & $b, "They're different")
EndIf

It's always the best to convert both arguments to the same "level" (Uppercase) before comparing. Then you are more flexible.

btw: I do not really know why it's different on special characters, but I mostly convert two strings before I compare them. That's why I never recognized such a problem :o

UTA

Edited by UTA
Posted

I'm not quite sure if that is a bug. I'm too lazy to test it in another programming language. I suppose that it is a "feature" :o which is based on the special characters. But as I said: I'm not sure...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...