0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

MacのExcelでUTF-8のCSVを開く時に日本語が文字化けしないようにする

Posted at

たまにコマンド忘れるので備忘録用。

内容

MicrosoftのExcelでUTF-8のCSVを開く際、BOMを付けてないと文字化けする。

事前準備

Microsoft OfficeとNKFのインストール。

$ brew install microsoft-office
$ brew install nkf

確認

UTF-8のCSVを作成してExcelで開いてみる。

$ touch sample.csv
$ nkf --overwrite --oc=UTF-8 sample.csv
$ echo "テスト用文言" > sample.csv

文字化けしている。

$ open -a /Applications/Microsoft\ Excel.app sample.csv

Screen Shot 2023-07-24 at 10.47.18.png

対応

先程Excelで開いたsample.csvを閉じる。

BOMを付与する。

$ nkf --overwrite --oc=UTF-8-BOM sample.csv

文字化けが改善される。

$ open -a /Applications/Microsoft\ Excel.app sample.csv

Screen Shot 2023-07-24 at 10.48.27.png

感想

  • NKFのコマンド忘れるので、Automatorとかでワークフロー化した方が良いのかもだが、設定した事を忘れて勝手に上書きされ、不具合時にハマりそうなのも怖い。
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?