How to remove BOM in Intellij Idea
Asked Answered
D

4

9

I'd like to remove Bite Order Masks from my
UTF-8 files in Intellij IDEA, how can I do this?

The problem is that if I'm trying to do it via other editors (e.g. Akelpad),
when I modify the file later in IDEA it somehow remembers that BOM
was present and adds it to my file again (((

Disport answered 24/10, 2011 at 7:58 Comment(0)
H
5

There is no such action to remove BOM from UTF-8 files in IntelliJ IDEA. There was a bug that BOM is removed, but it was fixed a long time ago.

When you remove BOM externally, make sure the file is synchronized with editor, try File | Synchronize.

If IntelliJ IDEA still thinks that this file has BOM, please file an issue with the steps to reproduce.

Headachy answered 24/10, 2011 at 8:22 Comment(1)
+1 for the File | Synchronize hint. IntelliJ is not able to aptly recognize external BOM changes, but this helps. Still, any further change to the same file, inside IntelliJ, will bring the BOM back... :-/ (IntelliJ CE 12). AFAIK the only way of making this REALLY annoying behavior go away is 1) closing IntelliJ, 2) remove the *&¨*&#ing BOM and 3) reopening it.Toffey
C
12

Tested on PHPStorm 8:

Right click on a file in the project tree, click on "Remove BOM"

(Not sure if it exists on the base platform, comments will be helpful)

Clougher answered 2/7, 2015 at 13:14 Comment(2)
If it's not shown in the file context menu, search for BOM in Help -> Find Action.Concubine
With the new UI it's under Tools in the right-click menuHerne
H
5

There is no such action to remove BOM from UTF-8 files in IntelliJ IDEA. There was a bug that BOM is removed, but it was fixed a long time ago.

When you remove BOM externally, make sure the file is synchronized with editor, try File | Synchronize.

If IntelliJ IDEA still thinks that this file has BOM, please file an issue with the steps to reproduce.

Headachy answered 24/10, 2011 at 8:22 Comment(1)
+1 for the File | Synchronize hint. IntelliJ is not able to aptly recognize external BOM changes, but this helps. Still, any further change to the same file, inside IntelliJ, will bring the BOM back... :-/ (IntelliJ CE 12). AFAIK the only way of making this REALLY annoying behavior go away is 1) closing IntelliJ, 2) remove the *&¨*&#ing BOM and 3) reopening it.Toffey
M
3

Intellij Idea has an option, File->Remove Bom, but it looks doesn't work very well, I got "This file has mandatory Bom" error

The following tips work for me

1) create new empty file (for example: temp123.java)

2) make sure that code-page/encoding for that file is UTF-8

3) copy whole content from original to newly created file (select all, copy, go > to another tab, paste) and save

I referenced link below, can be combined with Intellij Idea File->File Encoding-> Reload/Convert to UTF-8

IDEs Support: Remove BOM from file - how ?

Mislead answered 2/5, 2020 at 10:31 Comment(0)
B
0

I had the same Problem.

I found this issue and a "works for me"-fix: http://youtrack.jetbrains.com/issue/IDEA-86880#comment=27-386505

Hope it helps

Bailiwick answered 30/9, 2012 at 13:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.