From: David Vallner Date: 2006-02-21T11:51:52+09:00 Subject: Re: accents and String#tr Dňa Utorok 21 Február 2006 00:28 Xavier Noria napísal: > I wrote this method > > def self.normalize_for_sorting(s) > return nil unless s > norm = s.downcase > norm.tr!('ÁÉÍÓÚ', 'aeiou') > norm.tr!('ÀÈÌÒÙ', 'aeiou') > norm.tr!('ÄËÏÖÜ', 'aeiou') > norm.tr!('ÂÊÎÔÛ', 'aeiou') > norm.tr!('áéíóú', 'aeiou') > norm.tr!('àèìòù', 'aeiou') > norm.tr!('äëïöü', 'aeiou') > norm.tr!('âêîôû', 'aeiou') > norm > end > > to normalize strings for sorting. This script is UTF-8, everything is > UTF-8 in my application, $KCODE is 'u'. > > But it does not work, examples: > > Andrés -> andruos > López -> luupez > Pérez -> puorez > > I tried to "force" it with Iconv.conv('UTF-8', 'ASCII', 'aeiou') to > no avail. Any ideas? > > -- fxn Apparently, not all String methods were created equal: david@chello082119107152:~$ irb irb(main):001:0> $KCODE = 'u' => "u" irb(main):002:0> require 'jcode' => true irb(main):003:0> "Andrés".tr("áéíóú", "aeiou") => "Andres" jcode to the rescue! David Vallner