DEV Community

KOGA Mitsuhiro
KOGA Mitsuhiro

Posted on • Originally published at qiita.com

Windowsのメモ帳でソースコードを保存してはいけない

問題

Windowsのメモ帳で文字コードをUTF-8で保存すると必ずBOM有りになります。

このBOMが曲者で原因不明のコンパイルエラーになったり、差分比較ツールでファイルの先頭に謎の差分が出てきたり、Gitでバイナリ扱いになったりと何一ついい事がありません。

また、文字コードにUnicodeを選択して保存すると、実際はUTF-16で保存されます。
紛らわしいですね。

追記

image.png
Windows 10 May 2019 Update 1903のメモ帳からBOMなしUTF-8がデフォルトの保存形式になりました。
また紛らわしかったUnicodeがUTF-16 LEとUTF-16 BEになりました。

対処方法

Windows 10 May 2019 Update 1903以降

メモ帳で保存時にUTF-8で保存する。

Windows 10 May 2019 Update 1903より前

残念な事にメモ帳はBOM無しUTF-8で保存できません。
無用なトラブルを避ける為に、メモ帳の使用は避けましょう。

参考

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo 📊✨

Top comments (0)