6.
nkfは、Network KanjiFilterの略で、ネットワーク用漢字コード変換フィルタのことです。nkfの特徴は、入力漢字コード系の統計的な自動認識機能です。ユーザは、入力する漢字コードを意識することなく、目的の文字コードに変換することができます。今回は、CentOSにyumコマンドを用いて、nkfコマンドをインストールしてみます。薫@c1$ sudo yum install nkfPassword:Loading "installonlyn" pluginSetting up Install ProcessSetting up repositoriesbase 100% |=========================| 1.1 kB 00:00updates 100% |=========================| 951 B 00:00addons 100% |=========================| 951 B 00:00extras 100% |=========================| 1.1 kB 00:00Reading repository metadata in from local filesprimary.xml.gz 100% |=========================| 352 kB 00:00updates : ################################################## 764/764Added 206 new packages, deleted 0 old in 9.33 secondsprimary.xml.gz 100% |=========================| 77 kB 00:00extras : ################################################## 302/302Added 66 new packages, deleted 2 old in 2.37 secondsParsing package install argumentsResolving Dependencies--> Populating transaction set with selected packages. Please wait.---> Downloading header for nkf to pack into transaction set.nkf-2.07-1.1.fc6.i386.rpm 100% |=========================| 5.2 kB 00:00---> Package nkf.i386 0:2.07-1.1.fc6 set to be updated--> Running transaction checkDependencies Resolved============================================================================= Package Arch Version Repository Size=============================================================================Installing: nkf i386 2.07-1.1.fc6 base 111 kTransaction Summary=============================================================================Install 1 Package(s)Update 0 Package(s)Remove 0 Package(s)Total download size: 111 kIs this ok [y/N]: yDownloading Packages:(1/1): nkf-2.07-1.1.fc6.i 100% |=========================| 111 kB 00:04Running Transaction TestFinished Transaction TestTransaction Test SucceededRunning Transaction Installing: nkf ######################### [1/1]Installed: nkf.i386 0:2.07-1.1.fc6Complete!薫@c1$ nkf -vUSAGE: nkf(nkf32,wnkf,nkf2) -[flags] [in file] .. [out file for -O flag]Flags:b,u Output is buffered (DEFAULT),Output is unbufferedj,s,e,w Outout code is JIS 7 bit (DEFAULT), Shift JIS, EUC-JP, UTF-8N After 'w' you can add more options. -w[ 8 [0], 16 [[BL] [0]] ]J,S,E,W Input assumption is JIS 7 bit , Shift JIS, EUC-JP, UTF-8 After 'W' you can add more options. -W[ 8, 16 [BL] ]t no conversioni[@B] Specify the Esc Seq for JIS X 0208-1978/83 (DEFAULT B)o[BJH] Specify the Esc Seq for ASCII/Roman (DEFAULT B)r {de/en}crypt ROT13/47h 1 katakana->hiragana, 2 hiragana->katakana, 3 bothv Show this usage. V: show versionm[BQN0] MIME decode [B:base64,Q:quoted,N:non-strict,0:no decode]M[BQ] MIME encode [B:base64 Q:quoted]l ISO8859-1 (Latin-1) supportf/F Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nlZ[0-3] Convert X0208 alphabet to ASCII 1: Kankaku to 1 space 2: to 2 spaces 3: Convert to HTML EntityX,x Assume X0201 kana in MS-Kanji, -x preserves X0201B[0-2] Broken input 0: missing ESC,1: any X on ESC-[($]-X,2: ASCII on NLO Output to File (DEFAULT 'nkf.out')I Convert non ISO-2022-JP charactor to GETAd,c Convert line breaks -d: LF -c: CRLF-L[uwm] line mode u:LF w:CRLF m:CR (DEFAULT noconversion)Long name options --ic=<input codeset> --oc=<output codeset> Specify the input or output codeset --fj --unix --mac --windows --jis --euc --sjis --utf8 --utf16 --mime --base64 Convert for the system or code --hiragana --katakana --katakana-hiragana To Hiragana/Katakana Conversion --prefix= Insert escape before troublesome characters of Shift_JIS --cap-input, --url-input Convert hex after ':' or '%' --numchar-input Convert Unicode Character Reference --fb-{skip, html, xml, perl, java, subchar} Specify how nkf handles unassigned characters --in-place[=SUFFIX] --overwrite[=SUFFIX] Overwrite original listed files by filtered result --overwrite preserves timestamp of original files -g --guess Guess the input code --help --version Show this help/the version For more information, see also man nkfNetwork Kanji Filter Version 2.0.7 (2006-06-13)Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),2000 S. Kono, COWCopyright (C) 2002-2006 Kono, Furukawa, Naruse, mastodonCentOSでは、/usr/bin にnkfコマンドがインストールされました。薫@c1$ which nkf/usr/bin/nkf薫@c1$ nkf -g /etc/fstabASCII