atom/encoding-selector

UTF8 File with BOM opened in Atom cause the BOM to be moved

Closed this issue · 2 comments

Gulix commented

Description

File previously created by another editor, in UTF8 with BOM, is messed up when edited by ATOM.
The BOM is treated as a normal character.

Steps to Reproduce

I got a simple text file encoded in UTF8 with BOM :

image

The ef bb bf code is the BOM. Then I open this file with atom.
When I select all the content of the file, I got this :

image

6 characters selected ? I only see 5. The BOM is present, as an invisible character. Also, when my cursor is on 1,1, and I moved to the right, the cursor is on 1,2 and still before the actual characters.

I then go to the start of my file (Ctrl+Start) and a new character. The file looks like this in Atom :

image

When I open it with an hexa editor, I got this :

image

The BOM character is now inside the body of the file, not at its start. Needless to say, it provokes havoc with some tools I use.

Is there a way to ignore the BOM character ? In order to prevent this ?

Expected behavior: The BOM stays always in the shadow, at the head of the file.

Actual behavior: The BOM is moved inside the file as a regular character.

Reproduces how often: Everytime

Versions

1.17.2 on Windows 7

This is a larger issue with Atom: see atom/atom#3427.

maybe someone can write a package for this issue