Skip to content

Commit

Permalink
Rename encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
n10v committed Jul 18, 2017
1 parent 2017222 commit bae247a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func main() {

// Set comment frame.
comment := id3v2.CommentFrame{
Encoding: id3v2.ENUTF8,
Encoding: id3v2.EncodingUTF8,
Language: "eng",
Description: "My opinion",
Text: "Very good song",
Expand Down
12 changes: 6 additions & 6 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func BenchmarkParseAndWrite(b *testing.B) {

// Set front cover.
pic := PictureFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
MimeType: "image/jpeg",
PictureType: PTFrontCover,
Description: "Front cover",
Expand All @@ -82,7 +82,7 @@ func BenchmarkParseAndWrite(b *testing.B) {

// Set USLT.
uslt := UnsynchronisedLyricsFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
Language: "eng",
ContentDescriptor: "Content descriptor",
Lyrics: "bogem/id3v2",
Expand All @@ -91,7 +91,7 @@ func BenchmarkParseAndWrite(b *testing.B) {

// Set comment.
comm := CommentFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
Language: "eng",
Description: "Short description",
Text: "The actual text",
Expand Down Expand Up @@ -128,7 +128,7 @@ func BenchmarkReuseTag(b *testing.B) {

// Set front cover.
pic := PictureFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
MimeType: "image/jpeg",
PictureType: PTFrontCover,
Description: "Front cover",
Expand All @@ -138,7 +138,7 @@ func BenchmarkReuseTag(b *testing.B) {

// Set USLT.
uslt := UnsynchronisedLyricsFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
Language: "eng",
ContentDescriptor: "Content descriptor",
Lyrics: "bogem/id3v2",
Expand All @@ -147,7 +147,7 @@ func BenchmarkReuseTag(b *testing.B) {

// Set comment.
comm := CommentFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
Language: "eng",
Description: "Short description",
Text: "The actual text",
Expand Down
16 changes: 8 additions & 8 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Example() {

// Set comment frame.
comment := id3v2.CommentFrame{
Encoding: id3v2.ENUTF8,
Encoding: id3v2.EncodingUTF8,
Language: "eng",
Description: "My opinion",
Text: "Very good song",
Expand Down Expand Up @@ -81,7 +81,7 @@ func ExampleTag_AddAttachedPicture() {
}

pic := id3v2.PictureFrame{
Encoding: id3v2.ENUTF8,
Encoding: id3v2.EncodingUTF8,
MimeType: "image/jpeg",
PictureType: id3v2.PTFrontCover,
Description: "Front cover",
Expand All @@ -97,7 +97,7 @@ func ExampleTag_AddCommentFrame() {
}

comment := id3v2.CommentFrame{
Encoding: id3v2.ENUTF8,
Encoding: id3v2.EncodingUTF8,
Language: "eng",
Description: "My opinion",
Text: "Very good song",
Expand All @@ -112,7 +112,7 @@ func ExampleTag_AddUnsynchronisedLyricsFrame() {
}

uslt := id3v2.UnsynchronisedLyricsFrame{
Encoding: id3v2.ENUTF8,
Encoding: id3v2.EncodingUTF8,
Language: "ger",
ContentDescriptor: "Deutsche Nationalhymne",
Lyrics: "Einigkeit und Recht und Freiheit...",
Expand Down Expand Up @@ -176,7 +176,7 @@ func ExampleCommentFrame_get() {
func ExampleCommentFrame_add() {
tag := id3v2.NewEmptyTag()
comment := id3v2.CommentFrame{
Encoding: id3v2.ENUTF8,
Encoding: id3v2.EncodingUTF8,
Language: "eng",
Description: "My opinion",
Text: "Very good song",
Expand Down Expand Up @@ -211,7 +211,7 @@ func ExamplePictureFrame_add() {
}

pic := id3v2.PictureFrame{
Encoding: id3v2.ENUTF8,
Encoding: id3v2.EncodingUTF8,
MimeType: "image/jpeg",
PictureType: id3v2.PTFrontCover,
Description: "Front cover",
Expand All @@ -233,7 +233,7 @@ func ExampleTextFrame_get() {
func ExampleTextFrame_add() {
tag := id3v2.NewEmptyTag()
textFrame := id3v2.TextFrame{
Encoding: id3v2.ENUTF8,
Encoding: id3v2.EncodingUTF8,
Text: "Happy",
}
tag.AddFrame(tag.CommonID("Mood"), textFrame)
Expand Down Expand Up @@ -261,7 +261,7 @@ func ExampleUnsynchronisedLyricsFrame_get() {
func ExampleUnsynchronisedLyricsFrame_add() {
tag := id3v2.NewEmptyTag()
uslt := id3v2.UnsynchronisedLyricsFrame{
Encoding: id3v2.ENUTF8,
Encoding: id3v2.EncodingUTF8,
Language: "ger",
ContentDescriptor: "Deutsche Nationalhymne",
Lyrics: "Einigkeit und Recht und Freiheit...",
Expand Down
10 changes: 5 additions & 5 deletions id3v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,30 @@ const (
// Available encodings.
var (
// ISO-8859-1.
ENISO = util.Encoding{
EncodingISO = util.Encoding{
Key: 0,
TerminationBytes: []byte{0},
}

// UTF-16 encoded Unicode with BOM.
ENUTF16 = util.Encoding{
EncodingUTF16 = util.Encoding{
Key: 1,
TerminationBytes: []byte{0, 0},
}

// UTF-16BE encoded Unicode without BOM.
ENUTF16BE = util.Encoding{
EncodingUTF16BE = util.Encoding{
Key: 2,
TerminationBytes: []byte{0, 0},
}

// UTF-8 encoded Unicode.
ENUTF8 = util.Encoding{
EncodingUTF8 = util.Encoding{
Key: 3,
TerminationBytes: []byte{0},
}

Encodings = []util.Encoding{ENISO, ENUTF16, ENUTF16BE, ENUTF8}
Encodings = []util.Encoding{EncodingISO, EncodingUTF16, EncodingUTF16BE, EncodingUTF8}
)

// Open opens file with name and passes it to OpenFile.
Expand Down
10 changes: 5 additions & 5 deletions tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (tag *Tag) Title() string {
}

func (tag *Tag) SetTitle(title string) {
tag.AddFrame(tag.CommonID("Title/Songname/Content description"), TextFrame{Encoding: ENUTF8, Text: title})
tag.AddFrame(tag.CommonID("Title/Songname/Content description"), TextFrame{Encoding: EncodingUTF8, Text: title})
}

func (tag *Tag) Artist() string {
Expand All @@ -200,7 +200,7 @@ func (tag *Tag) Artist() string {
}

func (tag *Tag) SetArtist(artist string) {
tag.AddFrame(tag.CommonID("Lead artist/Lead performer/Soloist/Performing group"), TextFrame{Encoding: ENUTF8, Text: artist})
tag.AddFrame(tag.CommonID("Lead artist/Lead performer/Soloist/Performing group"), TextFrame{Encoding: EncodingUTF8, Text: artist})
}

func (tag *Tag) Album() string {
Expand All @@ -209,7 +209,7 @@ func (tag *Tag) Album() string {
}

func (tag *Tag) SetAlbum(album string) {
tag.AddFrame(tag.CommonID("Album/Movie/Show title"), TextFrame{Encoding: ENUTF8, Text: album})
tag.AddFrame(tag.CommonID("Album/Movie/Show title"), TextFrame{Encoding: EncodingUTF8, Text: album})
}

func (tag *Tag) Year() string {
Expand All @@ -218,7 +218,7 @@ func (tag *Tag) Year() string {
}

func (tag *Tag) SetYear(year string) {
tag.AddFrame(tag.CommonID("Year"), TextFrame{Encoding: ENUTF8, Text: year})
tag.AddFrame(tag.CommonID("Year"), TextFrame{Encoding: EncodingUTF8, Text: year})
}

func (tag *Tag) Genre() string {
Expand All @@ -227,7 +227,7 @@ func (tag *Tag) Genre() string {
}

func (tag *Tag) SetGenre(genre string) {
tag.AddFrame(tag.CommonID("Content type"), TextFrame{Encoding: ENUTF8, Text: genre})
tag.AddFrame(tag.CommonID("Content type"), TextFrame{Encoding: EncodingUTF8, Text: genre})
}

// iterateOverAllFrames iterates over every single frame in tag and calls
Expand Down
16 changes: 8 additions & 8 deletions tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,39 @@ const (

var (
frontCover = PictureFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
MimeType: "image/jpeg",
PictureType: PTFrontCover,
Description: "Front cover",
}
backCover = PictureFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
MimeType: "image/jpeg",
PictureType: PTBackCover,
Description: "Back cover",
}

engUSLF = UnsynchronisedLyricsFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
Language: "eng",
ContentDescriptor: "Content descriptor",
Lyrics: "bogem/id3v2",
}
gerUSLF = UnsynchronisedLyricsFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
Language: "ger",
ContentDescriptor: "Inhaltsdeskriptor",
Lyrics: "Einigkeit und Recht und Freiheit",
}

engComm = CommentFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
Language: "eng",
Description: "Short description",
Text: "The actual text",
}
gerComm = CommentFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
Language: "ger",
Description: "Kurze Beschreibung",
Text: "Der eigentliche Text",
Expand Down Expand Up @@ -317,7 +317,7 @@ func TestInvalidLanguageCommentFrame(t *testing.T) {

tag := NewEmptyTag()
tag.AddCommentFrame(CommentFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
Language: "en", // should be "eng" according to ISO 639-2
Text: "The actual text",
})
Expand All @@ -339,7 +339,7 @@ func TestInvalidLanguageUSLF(t *testing.T) {

tag := NewEmptyTag()
tag.AddUnsynchronisedLyricsFrame(UnsynchronisedLyricsFrame{
Encoding: ENUTF8,
Encoding: EncodingUTF8,
Language: "en", // should be "eng" according to ISO 639-2
Lyrics: "Lyrics",
})
Expand Down
2 changes: 1 addition & 1 deletion util/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package util
// You can set encoding by yourself like this:
//
// comment := id3v2.CommentFrame{
// Encoding: id3v2.ENISO,
// Encoding: id3v2.EncodingISO,
// Language: "eng",
// Description: string([]byte{68, 101, 115, 99}),
// Text: string([]byte{84, 101, 120, 116}),
Expand Down

0 comments on commit bae247a

Please sign in to comment.