# UTF-8 -\> iso8859-15

**URL:** <https://rubytalk.org/t/utf-8-iso8859-15/7028>\
**Category:** ruby-talk\
**Created:** [25 July 2003 20:42 UTC](https://rubytalk.org/t/utf-8-iso8859-15/7028 "2003-07-25T20:42:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andreas\_S2](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@Andreas\_S2](https://rubytalk.org/u/Andreas_S2)\
**Post date:** [25 July 2003 20:42 UTC](https://rubytalk.org/t/utf-8-iso8859-15/7028/1 "2003-07-25T20:42:31Z")

</div>

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](http://www.mikrocontroller.net)

---

<div class="post-metadata">

**Author:** ![Mark\_J\_Reed](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@Mark\_J\_Reed](https://rubytalk.org/u/Mark_J_Reed)\
**Post date:** [30 July 2003 02:24 UTC](https://rubytalk.org/t/utf-8-iso8859-15/7028/2 "2003-07-30T02:24:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![daz](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@daz](https://rubytalk.org/u/daz)\
**Post date:** [30 July 2003 02:24 UTC](https://rubytalk.org/t/utf-8-iso8859-15/7028/3 "2003-07-30T02:24:37Z")

</div>

[http://ruby-talk.org/76747](http://ruby-talk.org/76747)

?

> **···**
>
> “Mark J. Reed” [markjreed@mail.com](mailto: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

---

<div class="post-metadata">

**Author:** ![Mark\_J\_Reed](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@Mark\_J\_Reed](https://rubytalk.org/u/Mark_J_Reed)\
**Post date:** [30 July 2003 02:35 UTC](https://rubytalk.org/t/utf-8-iso8859-15/7028/4 "2003-07-30T02:35:21Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![why\_the\_lucky\_stiff1](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@why\_the\_lucky\_stiff1](https://rubytalk.org/u/why_the_lucky_stiff1)\
**Post date:** [30 July 2003 03:12 UTC](https://rubytalk.org/t/utf-8-iso8859-15/7028/5 "2003-07-30T03:12:37Z")

</div>

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](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](mailto: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.

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nobuyoshi\_Nakada](https://rubytalk.org/u/Nobuyoshi_Nakada)\
**Post date:** [30 July 2003 03:53 UTC](https://rubytalk.org/t/utf-8-iso8859-15/7028/6 "2003-07-30T03:53:52Z")

</div>

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](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](http://raa.ruby-lang.org/list.rhtml?name=shim-ruby16_18)
> 
> –  
> Nobu Nakada

---

<div class="post-metadata">

**Author:** ![Mark\_J\_Reed](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@Mark\_J\_Reed](https://rubytalk.org/u/Mark_J_Reed)\
**Post date:** [31 July 2003 03:36 UTC](https://rubytalk.org/t/utf-8-iso8859-15/7028/7 "2003-07-31T03:36:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nobuyoshi\_Nakada](https://rubytalk.org/u/Nobuyoshi_Nakada)\
**Post date:** [31 July 2003 04:02 UTC](https://rubytalk.org/t/utf-8-iso8859-15/7028/8 "2003-07-31T04:02:47Z")

</div>

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
