func (f *DescTextFrame) SetDescription(description string) error { diff, err := encodedbytes.EncodedDiff(f.encoding, description, f.encoding, f.description) if err != nil { return err } f.changeSize(diff) f.description = description return nil }
func (f *TextFrame) SetText(text string) error { diff, err := encodedbytes.EncodedDiff(f.encoding, text, f.encoding, f.text) if err != nil { return err } f.changeSize(diff) f.text = text return nil }
func (f *ImageFrame) SetEncoding(encoding string) error { i := byte(encodedbytes.IndexForEncoding(encoding)) if i < 0 { return errors.New("encoding: invalid encoding") } diff, err := encodedbytes.EncodedDiff(i, f.description, f.encoding, f.description) if err != nil { return err } f.changeSize(diff) f.encoding = i return nil }
func (f *DescTextFrame) SetEncoding(encoding string) error { i := byte(encodedbytes.IndexForEncoding(encoding)) if i < 0 { return errors.New("encoding: invalid encoding") } descDiff, err := encodedbytes.EncodedDiff(i, f.text, f.encoding, f.text) if err != nil { return err } newNullLength := encodedbytes.EncodingNullLengthForIndex(i) oldNullLength := encodedbytes.EncodingNullLengthForIndex(f.encoding) nullDiff := newNullLength - oldNullLength textDiff, err := encodedbytes.EncodedDiff(i, f.description, f.encoding, f.description) if err != nil { return err } f.changeSize(descDiff + nullDiff + textDiff) f.encoding = i return nil }