US-ASCII to UTF-8

M

Matt Beedle

I'm having trouble in with us-ascii strings. I have written a script
which receives emails straight from postfix. The emails are generally
encoded in "iso-8859-1", and I can't get all of the characters to
display properly, and I can't save to my mongodb database, either. Here
is an example problem string:

In irb by default it displays like this:

Gesch�ftsf�hrer

If I set $KCODE = 'iso-8859-1' then it gets a bit better:

Gesch\344ftsf\374hrer

But how do I now make that into the correct string:

Geschäftsführer

I have tried Iconv:

Iconv.iconv('iso-8859-1', 'utf-8', string)

Iconv::IllegalSequence: "\344ftsf\374hrer"

Please help!
 
B

Brian Candler

Matt said:
Iconv.iconv('iso-8859-1', 'utf-8', string)

Iconv::IllegalSequence: "\344ftsf\374hrer"

You just got the args the wrong way round. 'to' comes before 'from'.
(ri Iconv.iconv)
Geschäftsführer
 
M

Matt Beedle

Brian said:
You just got the args the wrong way round. 'to' comes before 'from'.
(ri Iconv.iconv)

Geschäftsführer

lol, ok, now I feel stupid. I've been messing around with this for
hours! Thanks very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top