Getting the right encoding in a SSH session using PuTTY

I moved my blog to www.blinkingcaret.com. It has a new design an lots of great new blog posts.

Click here to read this post there.

Recently I bought a cheap netbook to use as a media center at home, it came with Ubuntu 11.04. Everything worked fine out of the box (which is a major improvement for me compared with my previous experiences with Linux).

I just installed XBMC and I was done.

Recently I decided it would be nice if I could access it remotely (from Windows), so installed a ssh (openssh) server in it. It worked just fine, until I noticed that some applications would show strange characters, like if the text encoding was wrong, and that was what was happening, let me show you what I mean:

image

That application is called mc (Midnight Commander) and it’s a nice text-based file explorer. Also I’m using PuTTY to connect to my Linux box.

First thing I had to do was to check which encoding was being used in my server. To do that in Linux just open a terminal and type locale. I’m pretty sure if you do this you’ll get UTF-8 as I did.

[If you want to read a little bit about encoding and why it is that you get strange characters when you are using the wrong encoding I recommend this blog post by Joel Spolsky]

Now, to avoid the encoding problem you just have to configure PuTTY to use the right encoding so it can interpret those characters correctly. To do it just use the Window->Translation feature when configuring the connection:

image

And now, instead of all the â’s you get this:

image

If you’re thinking about doing something like this, another useful piece of information is how to do it while having a dynamic ip (assigned to you by your ISP and liable to change at any time). I’m using No-IP for it, which worked just fine for me in Ubuntu, here’s the link for it.



Leave a comment