1
我正在嘗試使用golang從mp3文件中讀取ID3標籤。
我得到結果。但是他們也包含一些二進制內容,如我的database viewer所示。如何從字符串中刪除二進制內容?
任何方式刪除golang的內容?
我正在嘗試使用golang從mp3文件中讀取ID3標籤。
我得到結果。但是他們也包含一些二進制內容,如我的database viewer所示。如何從字符串中刪除二進制內容?
任何方式刪除golang的內容?
但是,這是不夠的ID3V2,作爲表演in this commit,這確實有減磅的空字符。 看到使用cutset := string(rune(0))
,以及TrimRight(s string, cutset string)
,如例如strings.TrimRight(fd.Title(), cutset)
:
fd, err := id3.Open(path)
if err != nil {
item.Title = f.Name()
} else {
defer fd.Close()
cutset := string(rune(0))
title := strings.TrimRight(fd.Title(), cutset)
author := strings.TrimRight(fd.Artist(), cutset)
if len(title) > 0 {
item.Title = title
} else {
item.Title = author
if len(author) > 0 {
item.Title += " - "
}
item.Title += strings.TrimRight(f.Name(), cutset)
}
item.Subtitle = author
tcon := fd.Frame("TCON")
if tcon != nil {
item.Categories = append(item.Categories, Text{Value: strings.TrimRight(tcon.String(), cutset)})
}
item.PubDate = strings.TrimRight(formatYear(fd.Year()), cutset)
是啊,這爲我工作.......有時數據填充帶U的......我會想出出點什麼 –