Isaac Sloan - Web Developer, Photographer, Musician and Citizen of Earth
Banner700

How to safely remove Byte Order Marks (BOM) from files created on windows

October 15, 2017

The problem

If you read enough files created on a windows box you'll eventually run into this. ""\xEF\xBB\xBFyour expected string" instead of "your expected string". I recently ran into again while parsing some csv files exported in windows. In order to parse the string you'll need to remove what is called a Byte Order Mark.

Solution

Just search for "\xEF\xBB\xBF" and remove it.

How to safely remove Byte Order Marks (BOM) from files created on windows