On Wed, Mar 30, 2011 at 8:25 AM, ctdev <ctdev421 / gmail.com> wrote: > I also tried the following on a test string: > > ¨Â®åîãïä娢ÕÔÆ¸¢¬ ºéîöáìéä ½¾ ºòåðìáãåºõîäåæ ½¾ºòåðìáãåºòåðìáãå > => "?") > > But it doesn't seem to replace the invalid character(s) Could that be an optimization in encode: since the string is already thought to be UTF-8, just return it? > s = "PROT\xC9G=> "PROT\xC9G\u00C9" > s.encode("UTF-8", :invalid => :replace, :undef =>:replace, :replace => "?") => "PROT\xC9G\u00C9" > s. encode('ISO8859-9', :invalid => :replace, :undef =>:replace, :replace3D> "#"). encode("UTF-8", :invalid => :replace, :undef =>:replace, :replace => "?") => "PROT#G\u00C9"