お薦め ページ


メニュー

ハワイ島 遊覧飛行ツアー

ハワイ島 B&B・ホテル

ハワイ島 不動産情報

ハワイ島 情報・観光ガイド

ブログ(Blog)

その他

関連サイト

: 個別エントリー・アーカイブ :

2007年5月22日

libidn 付属の idn コマンド

前回のブログで FreeBSDに GNUの「 libidn 」がインストールされたわけだが、 と同時に コマンドライン上で libidn をテストできる 「idn」というコマンドもインストールされている。 では 早速 idnコマンドを試してみることにする。

まずは、オプションをつけずに そのまま実行してみると、
% idn
libidn 1.2
Copyright 2002, 2003, 2004, 2005, 2006, 2007 Simon Josefsson.
GNU Libidn comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Libidn under the terms of
the GNU Lesser General Public License.  For more information
about these matters, see the file named COPYING.LIB.
Type each input string on a line by itself, terminated by a newline character.
abc
abc

idn: tld_check_4z: Missing input
%
と このように表示される。 これで、libidn のバージョンが 1.2 であることが確認できる。 その後、入力を待っているので、 ここでは試しに「abc」+「エンターキー」と打ってみると、 そのまま 「abc」が表示された。 次の行で 何も入力せず「エンターキー」と打ってみると、 「idn: tld_check_4z: Missing input」というエラー・メッセージを表示して終了してしまった。

次に ヘルプを表示させてみる。
% idn -h
libidn 1.2

Command line interface to the internationalized domain name library.

All strings are expected to be encoded in the preferred charset used
by your locale.  Use `--debug' to find out what this charset is.  You
can override the charset used by setting environment variable CHARSET.

To process a string that starts with `-', for example `-foo', use `--'
to signal the end of parameters, as in `idn --quiet -a -- -foo'.

Usage: libidn [OPTIONS]... [STRINGS]...

  -h, --help               Print help and exit
  -V, --version            Print version and exit
  -s, --stringprep         Prepare string according to nameprep profile
  -d, --punycode-decode    Decode Punycode
  -e, --punycode-encode    Encode Punycode
  -a, --idna-to-ascii      Convert to ACE according to IDNA (default)
  -u, --idna-to-unicode    Convert from ACE according to IDNA
      --allow-unassigned   Toggle IDNA AllowUnassigned flag  (default=off)
      --usestd3asciirules  Toggle IDNA UseSTD3ASCIIRules flag  (default=off)
  -t, --tld                Check string for TLD specific rules
                             Only for --idna-to-ascii and --idna-to-unicode
                             (default=on)
  -p, --profile=STRING     Use specified stringprep profile instead
                             Valid stringprep profiles are `Nameprep', `iSCSI',
                             `Nodeprep', `Resourceprep', `trace', and
                             `SASLprep'.
      --debug              Print debugging information  (default=off)
      --quiet              Silent operation  (default=off)
%
と このようにヘルプが表示される。 ここに、locale により適切な charset が設定されている必要がある、 と書いてある。 また、現在の charset は --debug オプションをつけるとわかるようだ。

そでは idn コマンドに --debug オプションをつけてCHARSET の確認。 ここでは、無駄な表示を省くために、--quiet もつけた。
% idn --debug --quiet ""
Charset `US-ASCII'.
idn: tld_check_4z: Missing input
こでれ、Charset が「 US-ASCII 」であることがわかった。

そこで
% setenv CHARSET UTF-8
% printenv | grep CHARSET
CHARSET=UTF-8
% idn --debug --quiet ""
Charset `UTF-8'.
idn: tld_check_4z: Missing input
%
として Charset を「 UTF-8 」に変更して それを idn --debug コマンドで確認している。

以前のブログで 「日本語ドメイン名EXAMPLE.jp」というドメイン名は、 「xn--example-6q4fyliikhk162btq3b2zd4y2o.jp」 となる例を挙げていたが、これが idnコマンド で実際に変換されるかどうかテストしてみる。 上記のヘルプより、「-a」が「Convert to ACE according to IDNA (default)」とあるので
% idn --quiet -a 日本語ドメイン名example.jp
 xn--example-6q4fyliikhk162btq3b2zd4y2o.jp
%
それから、「-u」が「Convert from ACE according to IDNA」とあるので、
% idn --quiet -u xn--example-6q4fyliikhk162btq3b2zd4y2o.jp
日本語ドメイン名example.jp
%
となり、どちらの方向にも変換が正しく行われていることが確認できる。

【参考リンク】

カテゴリー: DNS・URL・URI     2007年5月22日 22:00

トラックバック

このエントリーのトラックバックURL:
http://www.skymerica.com/blog/yotsumoto/mt/mt-tb.cgi/807


コメント

コメントしてください




保存しますか?


 
ハワイ島での遊覧飛行ツアーとB&Bのスペシャリスト、スカイメリカ
Copyright © 2003,2009 Skymerica Corp. All rights reserved.