A UTF-8 byte order mark (BOM) is the byte sequence 0xEF,0xBB,0xBF.
To convert a UTF-8 encoded Buffer to a string, the Buffer must be converted to UTF-16. The BOM thus gets converted to the single 16-bit code point '\ufeff' (UTF-16 BOM).
Parameters
str: string
input string
Returns
string
string with BOM removed
Example
var str = removeUTF8BOM( '\ufeffbeep' );
// returns 'beep'
Removes a UTF-8 byte order mark (BOM) from the beginning of a string.
Notes
0xEF,0xBB,0xBF
.Buffer
to astring
, theBuffer
must be converted to UTF-16. The BOM thus gets converted to the single 16-bit code point'\ufeff'
(UTF-16 BOM).