UTF-8 -> iso8859-15

A

Andreas Schwarz

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

Thanks
Andreas
 
M

Mark J. Reed

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
 
D

daz

Mark J. Reed said:
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

http://ruby-talk.org/76747

?
 
M

Mark J. Reed

AS = Andreas Schwarz
MR = me
D = daz

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

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

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

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
 
W

why the lucky stiff

Mark said:
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.

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
 
M

Mark J. Reed

At Wed, 30 Jul 2003 12:12:37 +0900,
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
 
N

nobu.nokada

Hi,

At Thu, 31 Jul 2003 12:36:32 +0900,
Mark said:
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.
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top