Thursday, 28 October 2010

Japanese WHOIS fun

Recently, I wanted to look up info on a Japanese domain name. Being a command-line type of guy, I obviously did $ whois ac.jp and expected things to work out.

Well, things were a bit less helpful than I'd hoped.
$ whois ac.jp
Domain Information: [%I%a%$%s>pJs]
a. [%I%a%$%sL>]                 AC.JP
e. [$=$7$-$a$$]
f. [AH?%L>]                     3X=Q%I%a%$%s
g. [Organization]               Academic Domain
k. [AH?%<oJL]
l. [Organization Type]
m. [EPO?C4Ev<T]
n. [5;=QO"MmC4Ev<T]
p. [%M!<%`%5!<%P]               a.dns.jp
p. [%M!<%`%5!<%P]               b.dns.jp
p. [%M!<%`%5!<%P]               c.dns.jp
p. [%M!<%`%5!<%P]               d.dns.jp
p. [%M!<%`%5!<%P]               e.dns.jp
p. [%M!<%`%5!<%P]               f.dns.jp
p. [%M!<%`%5!<%P]               g.dns.jp
[>uBV]                          Reserved
[EPO?G/7nF|]
[@\B3G/7nF|]
[:G=*99?7]                      2005/03/30 17:37:52 (JST)
While I can figure out what I need here, why the garble? This is 2010 and I'm running in a UTF-8 locale with proper fonts; I should see hiragana/katakana/kanji just fine.

So I looked up the current WHOIS protocol. That's probably the shortest RFC I've ever seen.

The interesting bit: "The WHOIS protocol has no mechanism for indicating the character set in use." ... rrrright. Obviously not UTF-8 on this server.

Some trial and error, then.

$ whois ac.jp > gnark.txt
$ file gnark.txt
gnark.txt: ASCII English text, with escape sequences

Oh thank you. Very helpful. (irritated hacking ensues)

End product (bash function):
function jwhois { whois "$@" | iconv -f iso-2022-jp ; }
$ jwhois ac.jp
Domain Information: [ドメイン情報]
a. [ドメイン名]                 AC.JP
e. [そしきめい]
f. [組織名]                   学術ドメイン
g. [Organization]            Academic Domain
k. [組織種別]
l. [Organization Type]
m. [登録担当者]
n. [技術連絡担当者]
p. [ネームサーバ]              a.dns.jp
p. [ネームサーバ]              b.dns.jp
p. [ネームサーバ]              c.dns.jp
p. [ネームサーバ]              d.dns.jp
p. [ネームサーバ]              e.dns.jp
p. [ネームサーバ]              f.dns.jp
p. [ネームサーバ]              g.dns.jp
[状態]                        Reserved
[登録年月日]
[接続年月日]
[最終更新]                     2005/03/30 17:37:52 (JST)
Looks better, yes?

P.S. This was written using FreeBSD whois. Ubuntu whois acts completely differently - specifically asks for and shows English information in English locales, and breaks interestingly in the Japanese locales I've tested.

No comments: