Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs does not show special characters

I just found out that my program was not working because there was a strange (garbage?) character in a string that was present (got introduced while copy-pasting maybe) in a string supposed to be displayed to the user. Emacs was not showing me this strange character. I was just seeing a whitespace (as was expected).

After wasting three hours on this, I opened the file in Vim and I was able to see a couple of ? and slashes. How do I make Emacs show these characters like Vim does?

I am attaching the difference in how the two editors render text. Emacs Vim

like image 485
babon Avatar asked Sep 20 '25 10:09

babon


1 Answers

Those are not "strange" characters. They're (presumably) Unicode curly double-quote chars:

  • LEFT DOUBLE QUOTATION MARK, “ (codepoint 8220)
  • RIGHT DOUBLE QUOTATION MARK, ” (codepoint 8221)

You can tell that by putting your cursor just before each one and hitting C-u C-x =.

The fact that Emacs shows them as the chars they are, i.e., correctly, is normal. (And Emacs did not show them as whitespace.) The fact that your other editor can't display them is a bug, or lack of a feature.

If you type or paste chars that are perfectly renderable then don't expect Emacs to not render them correctly but instead to signal that you inserted some chars you didn't want to.

If you want Emacs to only render ASCII chars then tell it to do so. Then those "strange" chars will be rendered with octal escapes or in some other clearly visible way.

See the Emacs manual, node Coding Systems, and the Elisp manual, node Explicit Coding and Decoding.

like image 94
Drew Avatar answered Sep 23 '25 12:09

Drew