Message225829
| Author |
ncoghlan |
| Recipients |
benjamin.peterson, ezio.melotti, lemburg, ncoghlan, pitrou, pje, serhiy.storchaka, vstinner |
| Date |
2014年08月24日.15:23:03 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1408893784.05.0.955314394792.issue22264@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Current cryptic incantation that requires deep knowledge of the encoding system to follow:
data = data.encode("latin-1").decode("utf-8", "surrogateescape")
Replacement that is not only more self-documenting, but also gives you something specific to look up in order to learn more:
data = wsgiref.util.fix_encoding(data, "utf-8")
As a WSGI server, the standard library code mostly does this in the other direction, converting data from its original web server provided encoding *to* latin-1. |
|