PIB - 20210105: nkf - BOM の追加削除
やりたい事
UTF-8 のファイルに BOM を追加削除したい。
方法
nkf で以下のオプションを使うと楽なようだ。
--overwrite[=SUF] : timestamp を維持して上書き(維持したくない場合は --in-place[=SUF])
--oc=<encoding> : 出力コードの指定
BOM の追加
nkf --overwrite --oc=UTF-8-BOM <filename>
BOM の削除
nkf --overwrite --oc=UTF-8 <filename>
参考
Google:
nkf BOM
Qiita / takuharu / 2015-06-30:
BOMの追加・削除(UTF-8)