What has you here today?    work history (html) about me tajik bookmarks

PuTTY and Unicode non-locale keyboard input. 3rd of December, 2008 ANTE·MERIDIEM 12:18

PuTTY is a fine piece of software, a terminal emulator that is very comfortable for Unix users, written by an expert in the Win32 API with, on Windows, the speed and size advantages implicit in that. It has excellent support for working around the odd server bugs that many people come across, for UTF-8 output (with any number of other encodings), and for pasting UTF-8 text, for tunnelling, and a huge range of things.

Something that annoyed me about it earlier in the year was that it did contextual shaping for Arabic characters, but not for Persian and Urdu characters, so when one typed a Persian په or a گاف, the letters that the Arabs used would be shaped correctly, but the Persian-specific ones wouldn’t be. I sent them a patch for this, and they applied it. I don’t know if recent betas include this change; I use a local build myself, which also includes the other change I’m about to describe, and which I’m not going to point you towards, I don’t want the responsibility of making sure that no-one trojans it for you.

Another change that I was interested was in involves keyboard input on Win32. I use a modified keyboard layout that makes many more characters available to me than the normal layout does, and this works well with most apps. Not with PuTTY, though; keyboard input is effectively limited to characters that can be saved in the current language code page, the characters that Windows thinks necessary to write the language you use, more or less. I’ve written a patch to address this, and sent it to the PuTTY people, but I haven’t got a response, so I’m posting it here, in case anyone with the same problem Google™s it. (Let’s hope that the keywords I’m using are good!)

Changelog entry (which the PuTTY people don’t use, but I like the practice):

2008-11-23  Aidan Kehoe  <kehoea@parhasard.net>
 
        * ldiscucs.c (luni_send): 
        Check for negative length and treat that specially, as in
        ldisc_send(). 
        * windows/window.c (WndProc): 
        Pass TranslateKey a wchar_t buffer, treat the text it returns as
        Unicode. 
        * windows/window.c (TranslateKey): 
        Accept a wchar_t* output buffer, not unsigned char*.
        Accept output_count, giving the length of the output buffer.
        Explicitly use swprintf and wide strings when manipulating this
        buffer. Call ToUnicodeEx instead of ToAsciiEx on Windows NT 4 and
        above, avoiding the problem that characters available in the
        keyboard layout but not in the keyboard’s associated locale get
        dropped.
 

The patch is available here, or in compressed form here.


Christmas exam revision getting you down? :)

Our exams are the last two weeks of January, I haven’t started the revision for them just yet. But yes, there was procrastination of study involved in putting this post up, hah.

To the gentleman who searched for ‘putty pasting unicode’; this just works, but you need to turn on UTF-8 as the character set in Window -> Translation.

Comments are currently disabled.