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.

22 Blablas

  1. Daniel Fort says:

    Thnx man, that really hepled.

  2. Renny says:

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

  3. Santiajo says:

    Did you set in putty UTF-8 char set?

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

  4. Ozh says:

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

  5. Fabio Salles says:

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

  6. diego says:

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

  7. redCube says:

    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. redCube says:

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

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

  10. Sz.abi says:

    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. sempernoctis says:

    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. tom3k says:

    kick ass dood!

    thanks a million!

  13. Denis says:

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

    Denis

  14. rodgiarrr says:

    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. Whitesands says:

    Thanks man! This works!

  16. Ols says:

    Thanks for this!

  17. Ryan says:

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

  18. David says:

    %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. David says:

    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

  20. LiveChat.Zone says:

    thank you so much! This works great!

  21. Viacheslav says:

    Some Unicode characters (arrows, for example) looks like squares in Courier New font. ? – this symbol, for example. It shows fine in web browser with the same Courier New font.

  22. Viacheslav says:

    Oh, crap, it was "North West Arrow" symbol.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar and sign for a free account
Spam: Various spam plugins may be activated. I'll put pins in a Voodoo doll if you spam me.

Read more ?