How do I get accented letters to actually work on bash?

Ferdinando Randisi picture Ferdinando Randisi · Oct 26, 2012 · Viewed 11.9k times · Source

My bash installation on cygwin doesn't handle accented letters properly. I tried adding

set input-meta on    # to accept 8-bit characters
set output-meta on   # to show 8-bit characters
set convert-meta on  # to show it as character, not the octal representation

to my input rc, but this doesn't quite work yet. Indeed, if I type

$ echo ù

then before i press enter it is automatically changed to

$ echo \303

although the output is right, for I get

$ echo \303
ù

I get the same result for anyother accented letter. Usually though I use a non-italian keyboard, and I use autohotkey to substitute letters with an apostrophe after them with an accented letter. When this is the case, accented letters get substituted with a \302, and they print garbage depending on the letter: prints a 3y for a ù, a ¢ for an ò, and nothing for everething else.

How do I get all this to make sense?

EDIT: my locale settings, cygwin version and terminal are the following

$ uname -a
CYGWIN_NT-6.1-WOW64 ferdi-Asus 1.7.17(0.262/5/3) 2012-10-19 14:39 i686 Cygwin
$ locale
LANG=it_IT.UTF-8
LC_CTYPE="it_IT.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="it_IT.UTF-8"
LC_COLLATE="it_IT.UTF-8"
LC_MONETARY="it_IT.UTF-8"
LC_MESSAGES="it_IT.UTF-8"
LC_ALL=
$ tty
/dev/pty1

I'm invoking it simply clicking the Cygwin terminal link. It redirects to

C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -

The relevant part of the autohotkey script is the following

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
...
::avra'::avrà
::avro'::avrò
...

Answer

Rubens Mariuzzo picture Rubens Mariuzzo · Nov 23, 2012

To get accented letters on bash via Cygwin using Mintty 1.1.2 just do the following:

  1. Go to the menu (if you don't see any menu, right click on your Terminal).
  2. Click Options....
  3. Click Text.
  4. Change the Locale to C.
  5. Change the Character set to ISO-8859-1 (Western European).

Changing Locale and Character set in Mintty 1.1.2

Then test it:

Echoing accented letters in Mintty 1.1.2