Peter Cooper : UK Web 2.0 and Ruby on Rails consultant
Recent Posts
»Jay-Z: From Brooklyn to the Boardroom
»Prank Caller Submits Girl To Sexual Torture By Proxy
>Full archive
Other Posts
« Blogmusik: Free online iPodAre you on LinkedIn? »

Weird iconv problem


Any idea why this ugly solution works:

t = Tempfile.new('f')
t.write(f.content)
t.fsync
puts `iconv -f #{f.detect_charset} -t utf-8 #{t.path}`

But this clean pure Ruby solution fails:

puts Iconv.new(f.detect_charset, ''utf-8').iconv(f.content)

The latter gives this error:

in `iconv': "\310\355\362\345\360\355\345\362-\350\347\344\340\355\350\345"... (Iconv::IllegalSequence)

I have double checked that the file does not have any illegal sequences, and iconv converts it perfectly from the command line.. just not through Iconv in Ruby.




September 06, 2006 | Posted by peter | Comments (0)
Comments

Return to the homepage.
Privacy Policy