platform_specific_iconv - what's the rational behind that ?

12 views
Skip to first unread message

Thibaut Barrère

unread,
Mar 28, 2009, 2:41:42 PM3/28/09
to ruby-roo
Hello,

while working on some data processing stuff that rely on roo, I
noticed I had different behaviours on win32 (my production platform)
and mac os x (my development platform).

I digged into the code and noticed that on win32, content is converted
from iso-8859-1 whereas on other platforms, it is converted from
utf-8.

def platform_specific_iconv(value)
case RUBY_PLATFORM.downcase
when /darwin/
result = Iconv.new('utf-8','utf-8').iconv(value)
when /solaris/
result = Iconv.new('utf-8','utf-8').iconv(value)
when /mswin32/
result = Iconv.new('utf-8','iso-8859-1').iconv(value)
else
result = value
end # case
if every_second_null?(result)
result = remove_every_second_null(result)
end
result
end

In my case, using utf-8 to utf_8 everywhere ensured things work as
they should.

But I guess it's probably here for a good reason.

Can anyone shed some light on this ?

cheers,

-- Thibaut
Reply all
Reply to author
Forward
0 new messages