The Invisible Character Problem

Watch out for UTF 8203

This isn't a normal blog post about anything special it's just a warning for anyone out there that might find code behaving weirdly even though everything looks fine.

Some Background

Recently I needed to compile a project from a confluence page, and then after following all the steps to the letter the application still didn't work as expected, finding the problem took me a day or 2 because it wasn't being caught by the IDE or the compiler and the error was absolutely horrible.

Code Example

The line I copied from the confluence page, with the code that implements it is below

{​​​​​0}​​​​​://localhost.co.za/{​​​​​1}​​​​​

class Program
{
  static void Main(string[] args)
  {
    Console.Out.WriteLine(string.Format("{​​​​​0}​​​​​://localhost.co.za/{​​​​​1}​​​​​", "https", "authentication"));
  }
}

As you can see there is nothing visibly wrong with that line of code, and you're welcome to copy paste that into a console application and run it to view the results.

Where is the problem

Here is the crazy voodoo problem in the code, when you copy that line into an editor then put your cursor to the right of the closing quotation mark and start moving the cursor left with your keyboard arrow buttons, go ahead try it.

What you probably found is that you needed to press the arrow 7 times to the left of the quotation mark before getting to the '1' character.

What went wrong?

If you haven't figured it out yet, there are 6 invisible characters in between "\"" and "}" that is causing this. It seems like when copying from the Confluence page some of the formatting characters was replaced with the invisible character UTF 8203.

Comments

Popular Posts