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!
|