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

Report problems with documented functionality
rousni
Posts: 23
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

StringCaseSense Locale VAR := "‌‍‌" MsgBox % StrLen(VAR) ; 3 (3 zero-width spaces) If VAR = MsgBox Isn't this a bug
just me
Posts: 5563
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

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: 5260
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

q:: ;test zero-width characters with StringCaseSense Locale StringCaseSense, Locale ;note: two invisible characters are listed here: ;8204 200C ‌ ZERO WIDTH NON-JOINER ;8205 200D ‍ ZERO WIDTH JOINER VAR := Chr(8204) Chr(8205) Chr(8204) MsgBox, % StrLen(VAR) ;3 if VAR = MsgBox, 1 ;1 else MsgBox, 0 if (VAR = "") MsgBox, 1 ;1 else MsgBox, 0 return
homepage | tutorials
[code boxes are currently not working 100%]
[click the 'Reply with quote' button on a post to see the full indented text]
lexikos
Posts: 6200
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

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: 5260
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

;4511 characters were regarded as equal to a blank string q:: ;test StringCaseSense Locale, characters equal to a blank string vOutput := "" VarSetCapacity(vOutput, 100000*2) StringCaseSense, Locale vOutput := "", vCount := 0 Loop, 65535 if (Chr(A_Index) = "") vOutput .= A_Index "`t" Chr(A_Index) "`r`n", vCount += 1 Clipboard := vCount "`r`n" vOutput MsgBox, % Clipboard return
homepage | tutorials
[code boxes are currently not working 100%]
[click the 'Reply with quote' button on a post to see the full indented text]
Yer

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

05 Apr 2018, 15:17

Found this thread after reading about sneaky uses of zero width characters here https://www.ghacks.net/2018/04/05/how-t ... rprinting/ . Can someone tell me if and how AutoHotkey can be used to strip away all such zero width characters from any string? I'd like to make a hotkey to scrub the clipboard of such characters and then paste.
rousni
Posts: 23
Joined: 27 Dec 2014, 07:57

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

17 Aug 2018, 12:20

Code: Select all

StringCaseSense Locale X = � If (X = "") MsgBox Buggy 'StringCaseSense Locale' definitins

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 3 guests