This page looks best with JavaScript enabled

What is Illegal Character \8220 & \8221 Error Messages and How to fix it

 ·   ·  ☕ 2 min read
illegal characters in hello world
illegal characters in hello world

Today I was reading an e-book on Java programming language and enjoying and learning from it.

Every thing was fine until I reached up to arrays section. The problem from that exercise was a bit long, so instead of typing the whole code I decided to copy and paste, and then compile them. As soon as I typed:

javac arrayExample.java

I got not one, nor two but a whole bunch of 100 errors. This was the first time when I received so much error in a such small Java source file. I was surprised seeing that. For fixing it I tried as much as I can, following are which I tried:

  1. Changed curly braces to square braces and compiled again to see if it works.

  2. Checked every whitespace to be clear if I have hit and RETURN key, But this also didn’t work.

  3. I disabled the text wrapping of my text editor to checked if it was an indentation error.

None of them helped. Then at last I took help of Google and found a list of java compiler error. and I found that I was using Unicode character 8220 (also known as \u291c, 0x291c, “, left quote) and Unicode character 8221 (also known as \u291d, 0x291d, ”, right quote) instead of just using a simple Unicode 34 character (also known as \u0022, 0x22, “) which all programming language require.

What Actually Happened

When the book/e-book was being made, a word processor was used (not a text editor or IDE which we use in programming) which uses_ left quote and right quote instead of simple quotes. And when I copy-pasted the left and right quotes remained as they were.

Moral

Never copy paste anything! specially when you are programming or learning programming. Typing will not only make your typing speed fast but also will make you stop and think (and research the topics you don’t know).

I have just started this blog, please share it and subscribe to the newsletter below.

Share on

Santosh Kumar
WRITTEN BY
Santosh Kumar
Santosh is a Software Developer currently working with NuNet as a Full Stack Developer.