LoginSignup
2
2

More than 3 years have passed since last update.

不正なマルチバイト文字ですと表示された時の対処法

Posted at

不正なマルチバイト文字ですと出た時は、文字化けしてしまい読み込めていない可能性が高いです。

文字コードを調べる

まずはfileコマンドを用いて文字コードを調べる。

qiita.rb
file sample.csv

sample.csv: Non-ISO extended-ASCII text, with very long lines, with CRLF line terminators

Non-ISO extended-ASCII textは文字コードがShift-JISであることを示しています。

icovコマンドで文字コードを変換する

qiita.rb
iconv -f sjis -t utf8 sample.csv > utf8sample.csv

2
2
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
2
2