wstring comparison is failing

Vladimir Panteleev thecybershadow.lists at gmail.com
Mon Sep 23 20:41:36 UTC 2019


On Monday, 23 September 2019 at 20:38:03 UTC, Brett wrote:
> cast(wstring)entry.szExeFile == Name
> to!wstring(entry.szExeFile) == Name
>
> These all fail. The strings are clearly the same. I can compare 
> char by char and it works. latest D 2.088. The only thing is 
> that szExeFile is a static wchar array... which shouldn't 
> effect the comparison.

If you're comparing a static array, you're also comparing the 
bytes after the NUL character. Both of those conversions will 
give you a wstring with the length of the entire array, 
regardless of and including any NUL characters, so that's 
probably not what you want. fromStringz would probably be more 
appropriate there.



More information about the Digitalmars-d-learn mailing list