From: Robert Klemme Date: 2010-02-02T23:48:24+09:00 Subject: Re: [ENCODING] UTF8 hell 2010/2/2 Xavier Noëlle : > 2010/2/2 David Palm : >> There are several pieces to this. Even if the DB encoding and collation is utf8, doublecheck that the client connection is utf8 as well ("encoding: utf8" in database.yml for a Rails app I think). > > Not a Rails app :-) > >> str.force_encoding('UTF-8') is what you want to use I think. > > I already tried this method, but it lead me to the following error: in > `downcase!': invalid byte sequence in UTF-8 (ArgumentError). > > This is due to a call to str.downcase!() later in the application. > > Any idea to solve this ? :-) 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 -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/