- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2021-02-16T08:27:53+00:00","default:admin","admin")
-[[そうだったのか!! IT業界(1):文字コード:https://liginc.co.jp/532702]]
-[[【 nkf 】 文字コードを変換する:http://itpro.nikkeibp.co.jp/article/COLUMN/20060227/230849/]]
* unicode [#leb5b740]
-[[Unicodeのテキストファイルをほかの文字コードに変換するには:http://www.atmarkit.co.jp/flinux/rensai/linuxtips/448cnvunicode.html]]
-エスケープされたunicode文字列を確認したい場合
$ python -c "print u'\u30A8\u30B9\u30B1\u30FC\u30D7\u3055\u308C\u305F\u30E6\u30CB\u30B3\u30FC\u30C9'"
エスケープされたユニコード
**CJK統合漢字 [#o9161543]
**URO(Unified Repertoire and Ordering) [#bea96eca]
-Unicode 1.0.1 として割り当てられた漢字領域と漢字文字
**BMP(Basic Multilingual Plane) [#ub913591]
-文字の割り当て領域の1つで、16ビットで表せる範囲内の文字(U+0000〜U+FFFF)
**文字符号化方式 [#wbfaad68]
***UTF-8 [#cdbe6066]
-1文字を1〜6バイトの可変長の数値に変換
***UTF-16 [#h783d345]
-BMPは2バイト、それ以外は4バイトで表現
***UTF-32 [#gec1eb9e]
-全ての文字は固定長(4バイト)で表現
***UTF-7 [#e66b528b]
-[[UTF-7とは:http://wa3.i-3-i.info/word15293.html]]
* 変換ツール [#f64ee4ba]
** iconv [#yca920cb]
** [[lv:http://www.ff.iij4u.or.jp/~nrt/lv/]] [#kaf90d26]
** [[nkf:http://sourceforge.jp/projects/nkf/]] [#y00acc50]
-[[Linux上で文字コードを変換できるコマンドnkfのオプション一覧:http://jp.layer8.sh/reference/entry/show/id/745]]
$ nkf --help
Usage: nkf -[flags] [--] [in file] .. [out file for -O flag]
j/s/e/w Specify output encoding ISO-2022-JP, Shift_JIS, EUC-JP
UTF options is -w[8[0],{16,32}[{B,L}[0]]]
J/S/E/W Specify input encoding ISO-2022-JP, Shift_JIS, EUC-JP
UTF option is -W[8,[16,32][B,L]]
m[BQSN0] MIME decode [B:base64,Q:quoted,S:strict,N:nonstrict,0:no decode]
M[BQ] MIME encode [B:base64 Q:quoted]
f/F Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nl
Z[0-4] Default/0: Convert JISX0208 Alphabet to ASCII
1: Kankaku to one space 2: to two spaces 3: HTML Entity
4: JISX0208 Katakana to JISX0201 Katakana
X,x Convert Halfwidth Katakana to Fullwidth or preserve it
O Output to File (DEFAULT 'nkf.out')
L[uwm] Line mode u:LF w:CRLF m:CR (DEFAULT noconversion)
--ic=<encoding> Specify the input encoding
--oc=<encoding> Specify the output encoding
--hiragana --katakana Hiragana/Katakana Conversion
--katakana-hiragana Converts each other
--{cap, url}-input Convert hex after ':' or '%'
--numchar-input Convert Unicode Character Reference
--fb-{skip, html, xml, perl, java, subchar}
Specify unassigned character's replacement
--in-place[=SUF] Overwrite original files
--overwrite[=SUF] Preserve timestamp of original files
-g --guess Guess the input code
-v --version Print the version
--help/-V Print this help / configuration
-URLエンコード(出力:UTF-8)
$ echo '%A4%DB%A4%B2' | tr % = | nkf -wmQ
ほげ
-URLデコード(入力:UTF-8)
$ echo ほげ | nkf -wMQ | tr = %
%E3%81%BB%E3%81%92