If VAR <> ; false, while StrLen(VAR) > 0

Report problems with documented functionality
rousni
Posts: 17
Joined: 27 Dec 2014, 07:57

If VAR <> ; false, while StrLen(VAR) > 0

02 Feb 2018, 05:23

When VAR contains one or more zero-width spaces, and StringCaseSense Locale
If VAR <> ; false, while StrLen(VAR) > 0

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

StringCaseSense Locale
VAR := "‌‍‌"
MsgBox % StrLen(VAR) ; 3 (3 zero-width spaces)
If VAR =
MsgBox Isn't this a bug
just me
Posts: 5090
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: If VAR <> ; false, while StrLen(VAR) > 0

02 Feb 2018, 07:33

I'd say this is a bug:

Code: [Select all] [Download] GeSHi © Codebox Plus

MsgBox % StrLen(VAR) ; 3 (3 zero-width spaces)

Edit: I didn't notice the three invisible characters in Var := "".
Last edited by just me on 02 Feb 2018, 10:01, edited 1 time in total.
User avatar
jeeswg
Posts: 3569
Joined: 19 Dec 2016, 01:58
Location: UK

Re: If VAR <> ; false, while StrLen(VAR) > 0

02 Feb 2018, 08:07

It does seem to be bug-like. Btw the 3 characters you use are 8204, 8205, 8204.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

lexikos
Posts: 5686
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: If VAR <> ; false, while StrLen(VAR) > 0

09 Feb 2018, 03:33

What makes you think that they aren't equal?

If a locale-sensitive comparison tells you the strings are equal, that is because the system considers the strings to be equal under the rules defined by the current locale. This behaviour comes directly from lstrcmpiW, which performs the comparison with CompareStringEx.

Code: [Select all] [Download] GeSHi © Codebox Plus

s1 := "a‌‍‌b"  ; there are 3 zero-width spaces in the middle
s2 := "ab" ; just as it appears
MsgBox % (DllCall("lstrcmpiW", "wstr", s1, "wstr", s2) ? "not" : "") " equal"
MsgBox % (DllCall("CompareStringEx", "ptr", 0, "uint", 0x10
, "wstr", s1, "int", -1, "wstr", s2, "int", -1
, "ptr", 0, "ptr", 0, "ptr", 0)=2 ? "" : "not") " equal"
User avatar
jeeswg
Posts: 3569
Joined: 19 Dec 2016, 01:58
Location: UK

Re: If VAR <> ; false, while StrLen(VAR) > 0

12 Feb 2018, 13:25

Thanks for the info lexikos. Here's a little test.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 5 guests