I am looking for a utility method or constant in Java that will return me the bytes that correspond to the appropriate byte order mark for an encoding, but I can't seem to find one. Is there one? I really would like to do something like:
byte[] bom = Charset.forName( CharEncoding.UTF8 ).getByteOrderMark();
Where CharEncoding
comes from Apache Commons.
Java does not recognize byte order marks for UTF-8. See bugs 4508058 and 6378911.
The gist is that support was added, broke backwards compatibility, and was rolled back. You'll have to do BOM recognition in UTF-8 yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With