On Wed, Mar 30, 2011 at 8:25 AM, ctdev <ctdev421 / gmail.com> wrote:
> I also tried the following on a test string:
>
> =A0s.encode("UTF-8", :invalid =3D> :replace, :undef =3D>:replace, :replac=
e
> =3D> "?")
>
> 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 =3D "PROT\xC9G=C9"=3D> "PROT\xC9G\u00C9"
> s.encode("UTF-8", :invalid =3D> :replace, :undef =3D>:replace, :replace =
=3D> "?")
=3D> "PROT\xC9G\u00C9"

> s.
  encode('ISO8859-9', :invalid =3D> :replace, :undef =3D>:replace, :replace=
 =3D> "#").
  encode("UTF-8", :invalid =3D> :replace, :undef =3D>:replace, :replace =3D=
> "?")
=3D> "PROT#G\u00C9"