In: , , , ,
On: 2007 / 08 / 03 Viewed: 117902 times
Shorter URL for this post: http://ozh.in/fa

I was having a few reading problems on a server I've recently got my hands on: the locale is set to something like French UTF8, but Putty was displaying annoying é and stuff instead of accented characters.

I was expecting the solution to be something linuxish like read boring man pages till I finally decide it's not worth the hassle and live with it, but it was so simple that I'm still amazed. Just add the following lines (in your ~/.bash_profile for instance:

  1. echo -ne '\e%G\e[?47h\e%G\e[?47l'

No idea why it works, if it's for bash or any shell, but well, it just works. Cool ! (via)

Edit: As a few readers commented, there's something way easier to do in your PuTTy configuration. Read comments :)

Shorter URL

Want to share or tweet this post? Please use this short URL: http://ozh.in/fa

Metastuff

This entry "How To Display UTF8 in your Putty Bash Shell" was posted on 03/08/2007 at 10:05 pm and is tagged with , , , ,
Watch this discussion : Comments RSS 2.0.

19 Blablas

  1. 1
    Daniel Fort Ukraine »
    said, on 22/Sep/07 at 9:48 am # :

    Thnx man, that really hepled.

  2. 2
    Renny Russia »
    replied, on 16/Dec/07 at 10:24 pm # :

    Thanks again! Your post did save me so much time!!!

  3. 3
    Santiajo Spain »
    wrote, on 26/Feb/08 at 2:15 pm # :

    Did you set in putty UTF-8 char set?

    Configuration -> Window -> Translation -> UTF-8

  4. 4
    Ozh France »
    wrote, on 26/Feb/08 at 9:49 pm # :

    Santiajo » Oh… My… God. Never saw this setting before… Thanks! :)

  5. 5
    Fabio Salles Brazil »
    replied, on 03/Apr/08 at 2:14 pm # :

    Thank u 2!!(Ozh and Santiajo)
    This information has change my life!! &;p

  6. 6
    diego Colombia »
    wrote, on 10/Apr/08 at 11:03 pm # :

    espectacular….. no entiendo porque sirve….
    Pero funciona perfecto…
    Gracias

  7. 7
    redCube Germany »
    commented, on 11/Apr/08 at 8:49 pm # :

    In PuTTY 0.60 you can change the option "Window > Translation > Received data assumed to be in which character set:" to UTF-8. After this all received data will be interpreted as UTF-8 and displayed correctly.

  8. 8
    redCube Germany »
    wrote, on 11/Apr/08 at 10:14 pm # :

    Damn, might help to read other comments first. Sorry for an allready posted solution. ;)

  9. 9
    dasz.at - Benutzbare Technologie» ... Germany »
    pingback on 10/Feb/09 at 4:53 pm # :

    [...] are quite a few posts on how setting the "Window > Translation > Received Charset" of PuTTY to [...]

  10. 10
    Sz.abi Austria »
    thought, on 19/Feb/09 at 2:15 pm # :

    Hm,

    I have been using PuTTY for years.
    The first time I'd want to use UTF-8, but I experience a weird thing:

    1.) if I set in the Options Translation to "UTF-8″, everything gets correctly displayed, but I cannot input any characters beyond U+7F (traditional ASCII, not even Latin-1!!!). (whenever I press a key which has a para-ASCII number assigned, nothing gets sent to the PuTTY terminal. Nothing at all).

    2.) if I use the above described method (echo -ne '\e%G\e[?47h\e%G\e[?47l'), I get the same display and I CAN input any unicode number, which is however incorrectly translated to the terminal.

    So I'm stuck, actually neither 1), nor 2) helps.

    I'd love to hear some tips how to get PuTTY via the Translation-> UTF-8 working…

  11. 11
    sempernoctis United States »
    replied, on 31/Mar/09 at 5:47 pm # :

    As a point of clarification, the echo command configures the shell on the remote system (I'm not sure exactly what it does, but it is causing it to echo escape sequences through the console, which are commonly used for controlling various ways the console behaves). The PuTTY setting configures how your client handles data coming from the server. Presumably both your client and the server you are accessing would have to be configured to talk UTF-8 (or some other character set that supports wide characters, as long as they are configured to use the same one). My Debian Etch install with bash appears to handle UTF-8 by default; all I had to do was change the PuTTY configuration to deal with it properly. I would expect that older linux versions, some other distributions, or other shells might have different default configurations.

  12. 12
    tom3k Singapore »
    thought, on 10/Jun/09 at 4:23 pm # :

    kick ass dood!

    thanks a million!

  13. 13
    Denis France »
    wrote, on 30/Dec/09 at 8:05 pm # :

    Thank you very much! This is simple, and it works.

    Denis

  14. 14
    rodgiarrr Canada »
    commented, on 24/Apr/10 at 4:39 am # :

    thanks to the person who said:

    "The PuTTY setting configures how your client handles data coming from the server"

    that appears to be true:

    i looked and on the left side of the putty window, theres lots of menus that i had never looked into, one of them allows you to chose the charset putty uses.. it was ISO something just changed it to UTF8 (and reconnected) and now all the accents show up fine. no need to edit dirty bash files!

  15. 15
    Whitesands Bulgaria »
    wrote, on 09/Jul/12 at 6:50 pm # :

    Thanks man! This works!

  16. 16
    Ols Switzerland »
    said, on 27/Oct/12 at 3:19 pm # :

    Thanks for this!

  17. 17
    Ryan United States »
    wrote, on 07/Jan/13 at 2:24 am # :

    Not sure how I overlooked the option of setting PuTTY to use UTF-8. Thanks for the tip.

  18. 18
    David Switzerland »
    thought, on 17/Jan/14 at 1:08 pm # :

    %G sends xterm terminal (putty) code to select utf-8 character set

    [?47h select (dsiplay) xterm aternate screen buffer (it apparaently, amazingly has two screen buffers…)

    %G select utf-8 character set again on this screen

    [?47l back to normal screen buffer

    That is my understanding of it…

  19. 19
    David Switzerland »
    said, on 17/Jan/14 at 1:13 pm # :

    retrying shwoing 'esc' within brakcets….
    <esc>%G sends xterm terminal (putty) code to select utf-8 character set

    <esc>[?47h select (dsiplay) xterm aternate screen buffer (it apparaently, amazingly has two screen buffers…)

    <esc>%G select utf-8 character set again on this screen

    <esc>[?47l back to normal screen buffer

Leave a Reply

Comment Guidelines or Die

  • HTML: You can use these tags: <a href=""> <em> <i> <b> <strong> <blockquote>
  • Posting code: Post raw code (no <> &lt; etc) within appropriate tags : [php][/php], [css][/css], [html][/html], [js][/js], [sql][/sql], [xml][/xml], or generic [code][code]
  • Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar.
  • Spam: Various spam plugins on patrol. I'll put pins in a Voodoo doll if you spam me.
  • I will mark as Spam test comments, all comments with SEO names (ie "My Cool Online Shop" instead of "Joe") or containing forum-like signatures.

Read more ?