Forum: Ruby Transliteration problems

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D0338c0de4cb3c5c17300396159933d1?d=identicon&s=25 Axel Etzold (Guest)
on 2008-11-08 23:13
(Received via mailing list)
Dear all,

I'd like to transliterate some accented text, just removing the accents.
The encoding should be iso-8859-1 (source and destination).

I am on Ubuntu 8.04, and I get the following:


require "rubygems"
require "iconv"

s="caffè"p Iconv.iconv("ascii//translit","iso-8859-1",s)[0]   => "caff?"

Is there any way to get "caffe" ?

I read in some earlier post to a Ruby list that there are different
language locales to Iconv,
but I couldn't find how to specify any in Ruby Iconv :

http://groups.google.de/group/comp.lang.ruby/brows...

Thank you very much for your help!

Best regards,

Axel
3cb4fdcf13aad6a7dcae83876b0e784e?d=identicon&s=25 Josef 'Jupp' Schugt (Guest)
on 2008-11-09 00:09
(Received via mailing list)
On Sat, 08 Nov 2008 23:10:12 +0100, Axel Etzold <AEtzold@gmx.de> wrote:

> p Iconv.iconv("ascii//translit","iso-8859-1",s)[0]   => "caff?"

It seems as if either your system is broken or the file is not in ISO
8859-1 because that conversion *should* work and it does so on my Fedora
9:

Linux pen2.homeunix.net 2.6.26.6-79.fc9.x86_64 #1 SMP Fri Oct 17
14:20:33
EDT 2008 x86_64 x86_64 x86_64 GNU/Linux

$ iconv --version|head -1
iconv (GNU libc) 2.8

Are you sure that you do not get "caffA?" in place of "caff?"? That
would
suggest that the file is encoded using utf8, not an encoding of the ISO
8859 familiy.

Josef 'Jupp' Schugt
4a551074ddba4460f95d011c47190d0e?d=identicon&s=25 Henrik --- (malesca)
on 2008-11-09 11:11
(Received via mailing list)
This topic is locked and can not be replied to.