how can I add the iconv extension to Ruby?

M

Martin Elzen

Hi everyonel,

I want to be able to convert UTF-16 strings to UTF-8. From a usenet post I
understand that the standard 'iconv' ext for Ruby can do that. That same
post explained that you have to:
1) install iconv (this step I thought I could skip since iconv came in the
ruby-1.8.1.tar.gz)
2) set configure_args=--with-iconv-dir=<where_you_installed_it>
3) nmake

well, after doing so in the win32 directory for Ruby 1.8.1 I *do* see a
message fly by saying "compiling iconv", but after it's done a search for
iconv does NOT show either an iconv.so or an iconv.dll, and also nmake
reports that ruby.exe and rubyw.exe have not been changed.

I also have a directory tree with ruby-1.9.0-20040402-i386-mswin32 which
*does* contain an iconv.so file, but the version of irb in that directory
tree apparently doesn't know where to look for the .so, just starting up the
1.9.0.etc version of irb results in it showing a messagebox with the text:
"This application has failed to start because readline.dll was not found.
Re-installing the application may fix this problem." . After clicking on
the OK button irb does start running, but when I type require 'iconv' it
gives that same messagebox, except that it says it can't find 'iconv.dll'
and after clicking the OK button again I get to see the following lines in
irb:
LoadError: 126: The specified module could not be found. -
H:/ruby_190/lib/ruby/1.9/i386-mswin32/iconv.so
from H:/ruby_190/lib/ruby/1.9/i386-mswin32/iconv.so
from (irb):1
And what's more, the iconv.so it says it can't find is exactly in the
directory where irb says it can't find it!

So, my questions are: am I missing something really simple in that first
procedure (the one for Ruby 1.8.1)? Or, alternatively, how can I get the
Ruby 1.9 install to recognise that the .so files it can't find are exactly
where it's looking?

Martin

_________________________________________________________________
MSN Zoeken, voor duidelijke zoekresultaten! http://search.msn.nl
 
S

Sean Russell

Martin Elzen said:
I want to be able to convert UTF-16 strings to UTF-8. From a usenet post I
understand that the standard 'iconv' ext for Ruby can do that. That same
post explained that you have to:

This won't solve your iconv problems, but if all you want to do is
convert UTF-16 to UTF-8, a quick and dirty solution is:

def u16_to_u8(str)
array_enc=str.unpack('C*')
array_utf8 = []
2.step(array_enc.size-1, 2){|i|
array_utf8 << (array_enc.at(i+1) + array_enc.at(i)*0x100)
}
array_utf8.pack('U*')
end

--- SER
 
N

nobu.nokada

Hi,

At Mon, 3 May 2004 21:24:00 +0900,
Sean Russell wrote in [ruby-talk:99088]:
def u16_to_u8(str)
array_enc=str.unpack('C*')
array_utf8 = []
2.step(array_enc.size-1, 2){|i|
array_utf8 << (array_enc.at(i+1) + array_enc.at(i)*0x100)
}
array_utf8.pack('U*')
end

Wasn't this posted already?

def u16_to_u8(str)
str.unpack('n*').pack('U*')
end
 

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,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top