Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify zero-width character?

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:

x​y

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.

like image 699
Colonel Panic Avatar asked Sep 03 '15 09:09

Colonel Panic


People also ask

How do you find the zero width of a character?

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".

How do you find the zero width space in Word?

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.

How do I add a zero width space in Powerpoint?

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.


1 Answers

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:

Unicode explorer

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...)

like image 120
Jon Skeet Avatar answered Oct 20 '22 08:10

Jon Skeet