Sunday, October 25, 2009

Looking up Kanji/Hanzi quickly on zhongwen.com

Update: I've turned this into a Google App Engine app - http://zhongwenlookup.appspot.com/

zhongwen.com is an excellent dictionary that shows the decomposition of all Chinese characters and links to the entry for each component. It's the online version of Rick Harbaugh's "Chinese Characters: A Genealogy and Dictionary". I've spent plenty of time looking things up in it while learning Kanji (both online and in my own copy).

The one problem I have is that it's not possible to just paste a character into the search box and get to the entry. You can only search by radical, pronunciation and radical none of which lead directly to a single character. Tonight I finally got bored with that and was about to mail the author to see if he would add a search by character feature. While composing the mail I started poking a bit further and realised that the URL scheme for the site is based on the BIG5 encoding of Chinese characters and so I could just do it myself.

Here's a little bash script that takes characters as arguments and gives you back the zhongwen.com URLs and pass them to a command called browser which, for me, opens them in Firefox. Yes it's ugly. I tried to convert it to Perl but ran into encoding problems that I couldn't be bothered solving.

Invoke it as harb 宅 煉 to get the URLs for those 2 characters. Characters must passed as separate arguments (e.g. space separated).

Here's my browser script, while I'm at it

Post a Comment