Search code examples
utf-8character-encodingcygwing++eclipse-cdt

g++ curly quotes displayed incorrectly in console and "Problems" list


Recently, I switched from Visual Studio to Eclipse CDT. I've set it up beautifully such that the G++ compiler from my Cygwin installation can locate and compile my code without ado.

There is a minor grievance, however. Each time G++ reports a warning or error, the curly single quotes and appear as ‘ respectively ’. It seems like a character encoding problem; G++ or Cygwin is spitting out a character encoding that either CDT or Eclipse doesn't like.

This is only relevant Google result I could find, but setting the C++ environment variable LANG in Eclipse's preferences to C.UTF-8 or en_US.UTF-8 has no effect.

Running C++ from Cygwin directly reveals the curly single quotes. Is there any way of disabling these altogether? Is there some environment variable I can set or an argument I can pass?

In images

Eclipse shows hieroglyphs in various places:

Eclipse's problem screen Eclipse's console screen

Cygwin shows the correct symbols (ignore the fatal error):

Cywgin reveals the symbol


Solution

  • Yep, you either have to get Eclipse to display UTF-8, or to stop Cygwin gcc from using it. I don't know how to do the former, but you can do the latter by making sure that gcc is run with something like LANG=en_US.ISO-8859-1.