Check character code and line feed code on linux 文字コードと改行コードを調べる

Table of Contents

Check line feed code 改行コードを調べる

Line feed code should be LF for linux text files and you can check using a command of "file" as follows:

file test.f90
test.f90: ASCII text # LF (Unix, Linux, MAC)
test.f90: ASCII text, with CRLF line terminators (Windows)
file *.f90  # check all the files with extension of f90 

Convert to LF

Using nkf, you can convert from CRLF to LF:

nkf -Lu --overwrite test.f90  # to LF
nkf -Lw --overwrite test.f90  # to CRLF
nkf -Lu --overwrite *.f90     # all the files with the extension of f90 to LF

Check character code 文字コードを調べる

You can check character code using nkf -g:

nkf -g test.f90
  => Shift_JIS or EUC-JP or UTF-8

Convert to UTF-8

You can convert to UTF-8 using nkf -w:

nkf -w --overwrite test.f90   # automatically check the original character code
nkf -Sw --overwrite test.f90  # specify the original character code as Shift-JIS
nkf -Ew --overwrite test.f90  # specify the original character code as EUC-JP


メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください