❔ empty string not being recognized
I started with
if(name == "")
tried string.Empty
but when give it an empty name, and in debug I can see its an empty string, the statement is always false.
I am using unity, am I missing something obvious?39 Replies
Print out the length - is it definitely zero?
Because no, that code should work if the string is actually empty.
i can try that
I don't always trust the debugger...
it has 1 "length"
thats odd
because i also print the "name" and shows empty (nothing apears)
Try
IsNullOrWhitespace
Might be something like a newline character? Or convert it to a char[] and see what the char value is.didnt work
What's the char value?
i will see now
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
The suspense is killing me
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
x)
Need the numeric value
this means its a
"
? weird to me
Get that
So we can figure out what character it actually is
8203
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
zero width space
ZERO WIDTH SPACE
ups
yeps
i never knew it existed
I'm surprised IsNullOrWhitespace doesn't handle that.
ZWSP is not part of the space category iirc
at least the mystery is solved.. dont understand why this would be a default for empty input on anything ! i was completely lost
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
thanks guys, great help
mtreit#6470
REPL Result: Success
Console Output
Compile: 561.203ms | Execution: 63.676ms | React with ❌ to remove this embed.
IT HAS SPACE IN THE NAME! 😛
Blame the unicode consortium
btw why would we want a non character?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
That is a tricky one - the debugger showing it as an empty string really makes it kind of non-obvious.
because thats what it "looks" like
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
U+200B ZERO WIDTH SPACE - Unicode Explorer
U+200B ZERO WIDTH SPACE, copy and paste, unicode character symbol info, commonly abbreviated ZWSP, this character is intended for invisible word separation and for line break control; it has no width, but its presence between two characters does not prevent increased letter spacing in justification
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.