From: "Xavier NoĂ«lle" Date: 2010-02-23T20:10:20+09:00 Subject: Re: [ENCODING] UTF8 hell 2010/2/2 Robert Klemme : > You probably first want to find out whether the byte sequence is valid > UTF-8 or not.  For that you would need to look at the bytes in the > String.  I guess chances are that your String's byte sequence is NOT > valid UTF-8 OR you have a character in the string that has no > lowercase representation. > > Kind regards > > robert I dug into the problem and ended up with this line: self.force_encoding('UTF-8') Believing that the string #encoding was right was a wrong choice, then I assumed the database provided valid UTF8 strings. BUT (because, there's a but...), for some reason I don't understand, some strings are unwilling to work: Example: puts self => médicals self.each_byte {|b| print "#{b} "} => 109 233 100 105 99 97 108 115 233 is, AFAIK, a valid UTF8 character, but calling gsub(anything) (eg. self.gsub('ruby', 'zorglub')) on this string leads to: `gsub': invalid byte sequence in UTF-8 (ArgumentError). Where am I wrong ? TIA, -- Xavier NOELLE