UTF-8 -> iso8859-15

Simple Question: how can I convert UTF-8 strings (from REXML) to
iso8859-15?

Thanks
Andreas

···


AVR-Tutorial, über 350 Links
Forum für AVRGCC und MSPGCC
-> http://www.mikrocontroller.net

You would think that was a simple question, but I don’t have a simple
answer. The YAML homepage mentions a Ruby interface to the Iconv
library, but the link it provides back to RAA doesn’t find anything.
Was there an Iconv library that disappeared??

-Mark

···

On Fri, Jul 25, 2003 at 08:32:20PM +0000, Andreas Schwarz wrote:

Simple Question: how can I convert UTF-8 strings (from REXML) to
iso8859-15?

http://ruby-talk.org/76747

?

···

“Mark J. Reed” markjreed@mail.com wrote:

On Fri, Jul 25, 2003 at 08:32:20PM +0000, Andreas Schwarz wrote:

Simple Question: how can I convert UTF-8 strings (from REXML) to
iso8859-15?

You would think that was a simple question, but I don’t have a simple
answer. The YAML homepage mentions a Ruby interface to the Iconv
library, but the link it provides back to RAA doesn’t find anything.
Was there an Iconv library that disappeared??

-Mark

AS = Andreas Schwarz
MR = me
D = daz

Simple Question: how can I convert UTF-8 strings (from REXML) to
iso8859-15?

You would think that was a simple question, but I don’t have a simple
answer. The YAML homepage mentions a Ruby interface to the Iconv
library, but the link it provides back to RAA doesn’t find anything.
Was there an Iconv library that disappeared??

http://ruby-talk.org/76747
?

Thanks, but that doesn’t help in this case. The referenced message
includes a pointer to a port of libiconv to Windows, but libiconv I
already have. What I don’t have is the code to use it from Ruby.
I could write an extension, but what confused me was the reference on
the YAML page. It seemed to imply that this had already been done, and
even had a link that should have taken me to the Ruby module
on RAA, but no such module was there.

-Mark

Oh, sorry. I need to remove that link. The iconv lib is now included
with 1.8.0. WrItten by Nobu. If you need it for 1.6.8, I found the
link from FreeBSD ports (/usr/ports/converters/ruby-iconv):

http://member.nifty.ne.jp/nokada/archive/iconv-0.5.tar.gz

Also, please note that YAML 0.50 or newer don’t utilize iconv for
conversion and in fact doesn’t do any character set conversion.

_why

···

Mark J. Reed (markjreed@mail.com) wrote:

I could write an extension, but what confused me was the reference on
the YAML page. It seemed to imply that this had already been done, and
even had a link that should have taken me to the Ruby module
on RAA, but no such module was there.

Hi,

···

At Wed, 30 Jul 2003 12:12:37 +0900, why the lucky stiff wrote:

Oh, sorry. I need to remove that link. The iconv lib is now included
with 1.8.0. WrItten by Nobu. If you need it for 1.6.8, I found the
link from FreeBSD ports (/usr/ports/converters/ruby-iconv):

http://member.nifty.ne.jp/nokada/archive/iconv-0.5.tar.gz

This is out of date. The latest ruby-iconv for 1.6 is
contained in shim.

http://raa.ruby-lang.org/list.rhtml?name=shim-ruby16_18


Nobu Nakada

Oh! Well, in that case, the answer to the original question is simple.

require 'iconv'
iconv  = Iconv.new('ISO-8859-15', 'UTF-8')
latin9text = iconv.iconv(utf8text)

I find the (to, from) argument order counterintuitive, but that’s not Nobu’s
fault - it’s the order of the underlying C function iconv_open.

-Mark

···

At Wed, 30 Jul 2003 12:12:37 +0900, > why the lucky stiff wrote:

The iconv lib is now included with 1.8.0

Hi,

···

At Thu, 31 Jul 2003 12:36:32 +0900, Mark J. Reed wrote:

I find the (to, from) argument order counterintuitive, but that’s not Nobu’s
fault - it’s the order of the underlying C function iconv_open.

Agree. I often miss it too.


Nobu Nakada