From 030e21e7c231b1d1f4e96403b796c51afccf00b5 Mon Sep 17 00:00:00 2001 From: David Howden Date: Sun, 3 Jan 2016 23:00:45 +1100 Subject: [PATCH] Added DefaultUTF16WithBOMByteOrder for instances where no BOM is given. --- id3v2frames.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/id3v2frames.go b/id3v2frames.go index 5e1d058..c5fda33 100644 --- a/id3v2frames.go +++ b/id3v2frames.go @@ -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 }