Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Victor Kryukov
RE: Encoding id3v2 tags [ reply ]  
2010-01-04 13:35
Of course, it should be

f.tag.title = fix(f.tag.title)

in the code excerpt above

By: Victor Kryukov
Encoding id3v2 tags [ reply ]  
2010-01-04 13:33
Hello, I'm trying to fix some id3v2 tags that are incorrectly stored in iso8859-1 encoding. The following functions fixes the encoding problems in Ruby 1.9:

def fix(v)
v.force_encoding('CP1251').encode('UTF-8')
end

However, when I'm trying to execute something like

Mp3Info.open('myfile.mp3') do |f|
f.tags.title = fix(f.tags.title)
f.close
end

I'm getting the following error: /opt/local/lib/ruby/gems/1.9.1/gems/ruby-mp3info-0.6.13/lib/mp3info/id3v2.rb:277:in `block (2 levels) in to_bin': incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)

What am I doing wrong, and how can I get the desired behavior?

Many thanks!