Added DefaultUTF16WithBOMByteOrder for instances where no BOM is given.

This commit is contained in:
David Howden 2016-01-03 23:00:45 +11:00
parent 5fe43c28e4
commit 030e21e7c2

View File

@ -13,6 +13,10 @@ import (
"unicode/utf16"
)
// DefaultUTF16WithBOMByteOrder is the byte order used when the "UTF16 with BOM" encoding
// is specified without a corresponding BOM in the data.
var DefaultUTF16WithBOMByteOrder binary.ByteOrder = binary.LittleEndian
// ID3v2.2.0 frames (see http://id3.org/id3v2-00, sec 4).
var id3v22Frames = map[string]string{
"BUF": "Recommended buffer size",
@ -389,7 +393,7 @@ func decodeUTF16WithBOM(b []byte) (string, error) {
bo = binary.LittleEndian
default:
return "", fmt.Errorf("invalid byte order marker %x %x", b[0], b[1])
return decodeUTF16(b, DefaultUTF16WithBOMByteOrder), nil
}
return decodeUTF16(b[2:], bo), nil
}