8

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

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187

4 Answers4

5

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.

ak2
  • 6,629
  • 31
  • 27
  • 2
    Yes, that was it! I added an environment variable `LANG` with value `en_US.ISO-8859-1` in Eclipse preferences, and now the characters display more legibly. – Paul Lammertsma Mar 15 '10 at 13:52
5

According to gcc 4.0 release notes http://gcc.gnu.org/gcc-4.0/changes.html:

English-language diagnostic messages will now use Unicode quotation marks in UTF-8 locales. (Non-English messages already used the quotes appropriate for the language in previous releases.) If your terminal does not support UTF-8 but you are using a UTF-8 locale (such locales are the default on many GNU/Linux systems) then you should set LC_CTYPE=C in the environment to disable that locale. Programs that parse diagnostics and expect plain ASCII English-language messages should set LC_ALL=C. See Markus Kuhn's explanation of Unicode quotation marks for more information.

johnny
  • 4,024
  • 2
  • 24
  • 38
Rob Probin
  • 51
  • 1
  • 1
2

It worked for me too. The environment variable need to be set in the Eclipse preferences window under C/C++/Build/Environment. You need to add a new variable by clicking on the Add button. The variable name should be set to LANG and the value to en_US.ISO-8859-1. Does anyone know what is the cause of the problem? Cygwin, Eclipse, gcc???

amarchan
  • 21
  • 1
0

Answer 2 worked best for me when using gcc in a cygwin rxvt terminal.

Within my .bash_profile added:

# Disable unicode quotation marks for gcc

export LC_CTYPE=C

natersoz
  • 1,674
  • 2
  • 19
  • 29