32

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ò
...
12
  • 2
    Which Cygwin version are you using, and with what terminal? What's your locale setting, i.e. what are the values of LC_ALL, LC_CTYPE and LANG? In any case, convert-meta needs to be off for non-ASCII characters to work properly.
    – ak2
    Commented Oct 27, 2012 at 20:03
  • I edited my post to show what you asked. Turning off convert-meta doesn't seem to change anything actually. Commented Oct 28, 2012 at 10:04
  • Non-ASCII letters work fine for me wihtout convert-meta, and they stop working if I switch it on, which is not surprising looking at its description: "If set to ‘on’, Readline will convert characters with the eighth bit set to an ASCII key sequence by stripping the eighth bit and prefixing an ESC character, converting them to a meta-prefixed key sequence. The default value is ‘on’."
    – ak2
    Commented Oct 30, 2012 at 11:42
  • 3
    Just for the record, here's an excellent synopsis of things you should know about Unicode.
    – ghoti
    Commented Oct 30, 2012 at 22:30
  • 2
    Try ONE of the following: (1) revert all your input rc changes, restart your terminal, confirm that locale yields it_IT.UTF-8 and going to the mintty menu > Options > Text your locale is it_IT and your charset is UTF-8; backup your current autohkey script and use e.g. notepad++ to open your autohotkey script and convert to UTF-8 without BOM instead of ANSI. Try it out. If failed, (2) restore the backed up autohotkey, then in the mintty menu change the charset to CP1252 (ANSI codepage) for locale it_IT, export LC_ALL=it_IT.CP1252 and try again.
    – vladr
    Commented Nov 10, 2012 at 7:00

1 Answer 1

15

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

2
  • 1
    Thank you! This works when I use the regular italian layout, but not when I do insert accented letters via my autohotkey script. This should not be a big deal, since my main purpose is being able to write scripts using accents rather than issuing commands with accents directly in the shell. I'll give it a try and see how it goes. Commented Dec 1, 2012 at 13:41
  • I suggest using UTF-8 unless you have a specific reason to use ISO-8859-1. Of course that will affect how accented characters are stored. Commented May 11, 2021 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.