Visual Studio 2015 found an unexpected character in my code (error CS1056)
How can I identify what the character is? It's a zero-width character so I can't see it. I'd like to know exactly what it is so I can work out where it comes from and how to fix it with a find-and-replace (I have many similar errors).
Here's an example. There's a zero-width character between x and y in the quote below:
xy
It would be helpful just to tell me the name of the character in my example, but I'd also like to know generally how to identify characters myself.
Format character that affects the layout of text or the operation of text processes, but is not normally rendered. Signified by the Unicode designation "Cf" (other, format). The value is 15. The unicode codepoint 0x200b is known as "zero width space".
Alt + 8203 A zero-width space is, for the most part, invisible. It's a space that you can put into Word and other programs to divide up a long line of text without breaking it up visually.
A zero width space Alt+8203 (or from the Symbols menu a 'No-Width Optional Break') simply inserts a no width space. It does not create a line break.
I have a little bit of Javascript embedded within my explanation of Unicode which allows you to see the Unicode characters you copy/paste into a textbox. Your example looks like this:
Here you can see that the character is U+200B. Just searching for that will normally lead you to http://www.fileformat.info, in this case this page which can give you details of the character.
If you have the characters yourself within an application, Char.GetUnicodeCategory
is your friend. (Oddly enough, there's no Char.GetUnicodeCategory(int)
for non-BMP characters as far as I can see...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With