Menu

Commit [r9383]  Maximize  Restore  History

Simplify `to_unicode`.

The `charset` parameter to indicate the ''first'' encoding to try, by default "utf-8". The difference is that now specifying an encoding explicitly doesn't change the conversion to be in ''replace'' mode. Instead, if the first conversion fails, we use the failsafe 'latin1' encoding. If one really need a conversion in replacement mode, this must be done explicitly. A later simplification step will be to remove `charset` argument altogether, as "utf-8" is almost always the only sensible choice in our context.

Also `to_unicode` was using the `locale.getpreferredencoding()` encoding as a fallback since r3569, but there was no benefit from that change, and we should try to get away from using `locale` (#6953). Now we always use 'latin1' as a failsafe encoding.

cboos 2010-03-21

changed /trunk/trac/util/tests/text.py
changed /trunk/trac/util/text.py
/trunk/trac/util/tests/text.py Diff Switch to side-by-side view
Loading...
/trunk/trac/util/text.py Diff Switch to side-by-side view
Loading...
MongoDB Logo MongoDB