n10v / id3v2

🎵 ID3 decoding and encoding library for Go
https://pkg.go.dev/github.com/bogem/id3v2/v2
MIT License
340 stars 52 forks source link

Expose Tag's default encoding #35

Closed deanishe closed 6 years ago

deanishe commented 6 years ago

Perhaps I've missed something here. Adding my own TextFrames to Tags seems to be more complicated than it need be, as Tag doesn't export its default encoding.

The Tag.Set* convenience methods use TextFrame{Encoding: tag.defaultEncoding ...}.

Because Tag.defaultEncoding isn't exported, you need to re-implement Tag.setDefaultEncoding() to add your own TextFrame.

(I'm assuming I shouldn't just smush UTF-8 TextFrames into a Tag whose version is < 4.)

n10v commented 6 years ago

Done in 7e43476:

// DefaultEncoding returns default encoding of tag.
// Default encoding is used in methods (e.g. SetArtist, SetAlbum ...) for
// setting text frames without the explicit providing of encoding.
func (tag *Tag) DefaultEncoding() Encoding {
    return tag.defaultEncoding
}

// SetDefaultEncoding sets default encoding for tag.
// Default encoding is used in methods (e.g. SetArtist, SetAlbum ...) for
// setting text frames without explicit providing encoding.
func (tag *Tag) SetDefaultEncoding(encoding Encoding) {
    tag.defaultEncoding = encoding
}