LoginSignup
33
28

More than 5 years have passed since last update.

文字コード/改行コード変換コマンド nkf メモ

Posted at

文字コードを判別する

--guessの省略形が-g

$ nkf -g test.txt
Shift_JIS

文字コード変換

オプション

  • -j : JIS(ISO-2022-JP)
  • -e : EUC
  • -s : Shift-JIS
  • -w : UTF-8(BOM無し)

改行コード変換

オプション

  • -Lu : unix形式(LF)
  • -Lw : windows形式(CRLF)
  • -Lm : macintosh形式(CR)

実行例

UTF-8に変換する。--overwriteでファイルを上書きできる。リダイレクトで同じファイルを指定すると空ファイルになるので注意。

$ nkf -w --overwrite test.txt
33
28
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
28