Am I misunderstanding something here? I’m writing a complex medical imaging parser and have hit a bug.
Run this code:
Var s As String = "1.2.840.10008.1.2.1"
Var sLen As Integer = s.Length
// sLen should be 19 but is reported as being 21.
Break
Why is sLen
21 and not 19? Unless I am miscounting, there are 19 characters in 1.2.840.10008.1.2.1
Not only do I think this is a bug but it’s propagating throughout my code as String
comparisons are failing.
What does the text look like in the debugger?
There is some unknown character in the string. I also tried and got length as 21. but i cleared the value and manually typed the characters and got length as 19.
Use this :
Var s As String = “1.2.840.10008.1.2.1”
You’ve got a:
U+200B e2 80 8b ZERO WIDTH SPACE
in there.
In fact two of them.
So no bug, you have a bad string.
2 Likes
Dang - you guys are right.
What seems to have happened is that I cut and pasted several dozen strings and put them as constants in a class. I copied them from a website but there must have been some non-visible characters in them.
What a pain.
Thank you.
The IDE has a command somewhere to get rid of non-ASCII stuff - I’ve never used it but I’ve heard it mentioned on the forums a few times.
I find this website to be handy when looking to see what an odd sequence of possible UTF8 bytes corresponds to:
https://www.utf8-chartable.de/unicode-utf8-table.pl
Right-click in the text editor to see the option.
1 Like
Holy smoke - what great a find!
Would be nice if that existed in the text area you enter constants into…