# Help with Iconv needed

**URL:** <https://www.ruby-forum.com/t/help-with-iconv-needed/121628>\
**Category:** Ruby\
**Created:** [November 29, 2007, 1:50pm UTC](https://www.ruby-forum.com/t/help-with-iconv-needed/121628 "2007-11-29T13:50:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![strube](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@strube](https://www.ruby-forum.com/u/strube)\
**Post date:** [November 29, 2007, 1:50pm UTC](https://www.ruby-forum.com/t/help-with-iconv-needed/121628/1 "2007-11-29T13:50:35Z")

</div>

Can someone tell me what it is that I’m getting wrong here with “iconv”?  
I either get “IllegalSequence” or “Ã¤Ã¶Ã¼ÃŸ” are not encoded properly when  
using Iconv.conv while it looks good using backticks. ("IllegalSequence  
right now with the second. Ã„Ã–Ã¼ with the first anytime…)

require ‘rss/1.0’; require ‘rss/2.0’; require ‘open-uri’; require  
“iconv”

#source = “[http://www.sueddeutsche.de/app/service/rss/alles/rss.xml](http://www.sueddeutsche.de/app/service/rss/alles/rss.xml)”  
source = “[Panorama - WELT](http://www.welt.de/vermischtes/?service=Rss)”

content = “”; open(source) { |s| content = s.read }; rss =  
RSS::Parser.parse(content, false)

rss.items.each do |item|  
converted = `'#{item.title}' | iconv -c -f ISO-8859-1 -t UTF8`  
puts(Iconv.conv(‘ISO-8859-1’, ‘UTF-8’, item.title)); puts " "  
end

---

<div class="post-metadata">

**Author:** ![strube](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@strube](https://www.ruby-forum.com/u/strube)\
**Post date:** [November 30, 2007, 1:05am UTC](https://www.ruby-forum.com/t/help-with-iconv-needed/121628/2 "2007-11-30T01:05:22Z")

</div>

On Nov 29, 6:50 am, Marcus S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> content = “”; open(source) { |s| content = s.read }; rss =  
> RSS::Parser.parse(content, false)
> 
> ## rss.items.each do |item| converted = `'#{item.title}' | iconv -c -f ISO-8859-1 -t UTF8` puts(Iconv.conv(‘ISO-8859-1’, ‘UTF-8’, item.title)); puts " " end
> 
> Posted viahttp://www.ruby-forum.com/.

Not sure about the error, but I see two issues. First, this is an  
error…

`'#{item.title}' | iconv -c -f ISO-8859-1 -t UTF8`

I think you meant to echo the vale to the pipe…

`echo -n '#{item.title}' | iconv -c -f ISO-8859-1 -t UTF8`

Second, iso-8859-1 to utf-8 doesn’t appear to be the proper encoding.  
The following string…

Düsseldorf: Prominentengedrängel bei der Bambi-Verleihung

…is encoded as…

“D\303\203\302\274sseldorf: Prominentengedr\303\203\302\244ngel bei  
der Bambi-Verleihung”

…by iconv from the command prompt. But it should be…

“D\303\274sseldorf: Prominentengedr\303\244ngel bei der Bambi-  
Verleihung”

I’m not good with encodings and utf-8, so I can’t tell you the  
problem. I just know “umlaut u” should be 0xc3bc (\303\274), but it’s  
not doing that.

Regards,  
Jordan
