# Pure ruby iconv?

**URL:** <https://www.ruby-forum.com/t/pure-ruby-iconv/162193>\
**Category:** Ruby\
**Created:** [March 6, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/pure-ruby-iconv/162193 "2009-03-06T17:02:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [March 6, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/pure-ruby-iconv/162193/1 "2009-03-06T17:02:32Z")

</div>

Hi,

It looks like Rails 2.x requires the iconv library. Unfortunately,  
libiconv requires mingw or cygwin to build properly. Since I have  
neither, I’m in a bit of a bind.

I thought there was a pure Ruby library (or three) out there that  
could do what iconv does, but I’ve never done the research.

Specifically, it looks like ActiveSupport requires it:

activesupport-2.2.2\lib\active\_support\inflector.rb

# Replaces accented characters with their ascii equivalents.

def transliterate(string)  
Iconv.iconv(‘ascii//ignore//translit’, ‘utf-8’, string).to\_s  
end

Any suggestions? Or do I need to put a bounty out there for a pure  
ruby iconv now?

Regards,

Dan

PS - A comment in the code also suggests that method doesn’t function  
properly

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [March 6, 2009, 5:14pm UTC](https://www.ruby-forum.com/t/pure-ruby-iconv/162193/2 "2009-03-06T17:14:58Z")

</div>

On Mar 6, 2009, at 9:59 AM, Daniel B. wrote:

> Any suggestions? Or do I need to put a bounty out there for a pure  
> ruby iconv now?

I sure hope you’re planning to offer considerable more than $100 for  
that effort. This is no Zlib!

James Edward G. II

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [March 6, 2009, 6:05pm UTC](https://www.ruby-forum.com/t/pure-ruby-iconv/162193/3 "2009-03-06T18:05:27Z")

</div>

James G. wrote:

> On Mar 6, 2009, at 9:59 AM, Daniel B. wrote:
> 
> > Any suggestions? Or do I need to put a bounty out there for a pure  
> > ruby iconv now?
> 
> I sure hope you’re planning to offer considerable more than $100 for  
> that effort. This is no Zlib!

That’s for sure…Iconv is a brute. I’d love to see a pure Ruby version  
(and in this case we’d probably use it in JRuby as well), but it would  
mean a substantial amount of effort.

Not that I’m trying to scare anyone interested in doing it, of course 🙂

- Charlie

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [March 6, 2009, 6:53pm UTC](https://www.ruby-forum.com/t/pure-ruby-iconv/162193/4 "2009-03-06T18:53:03Z")

</div>

On Mar 6, 10:03 am, Charles Oliver N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> (and in this case we’d probably use it in JRuby as well), but it would  
> mean a substantial amount of effort.
> 
> Not that I’m trying to scare anyone interested in doing it, of course 🙂

Oh, sure, I could offer more money. But first I want to make sure  
there isn’t an alternative already out there.

BTW, it looks like Perl did it already with piconv, though I’m not  
sure how much of it depends on features within Perl itself:

> **[\- iconv(1), reinvented in perl - metacpan.org](https://metacpan.org/release/JHI/perl-5.8.1/view/ext/Encode/bin/piconv)**
>
> iconv(1), reinvented in perl

If there isn’t a working alternative I’ll probably handle this one  
differently, i.e. I’d setup a separate rubyforge project for it in  
advance, allow multiple developers (probably up to 3), hand pick the  
developers if there are too many volunteers, set some milestones and  
pay in increments.

However, it may not be necessary in the short term. I discovered,  
thanks to my Solaris box, that the way Rails is handling the  
redefinition of the transliterate method in inflector.rb is broken.  
It’s only checking the return value of Iconv.iconv, but not whether or  
not an error is raised.

Time to file a bug report and patch.

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [March 7, 2009, 1:12am UTC](https://www.ruby-forum.com/t/pure-ruby-iconv/162193/5 "2009-03-07T01:12:24Z")

</div>

Daniel B. wrote:

> Hi,
> 
> It looks like Rails 2.x requires the iconv library. Unfortunately,  
> libiconv requires mingw or cygwin to build properly. Since I have  
> neither, I’m in a bit of a bind.
> 
> I thought there was a pure Ruby library (or three) out there that  
> could do what iconv does, but I’ve never done the research.
> 
> Specifically, it looks like ActiveSupport requires it:
> 
> activesupport-2.2.2\lib\active\_support\inflector.rb
> 
> # Replaces accented characters with their ascii equivalents.
> 
> def transliterate(string)  
> Iconv.iconv(‘ascii//ignore//translit’, ‘utf-8’, string).to\_s  
> end
> 
> Any suggestions? Or do I need to put a bounty out there for a pure  
> ruby iconv now?

You could download mingw 🙂

> **[GitHub - oneclick/rubyinstaller: RubyInstaller for Windows - Build recipes](https://github.com/oneclick/rubyinstaller/tree/master)**
>
> master

Good luck!  
-=r
