⇤ ← Revision 1 as of 2007-07-13 02:50:11
846
Comment:
|
848
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
Paradoxically, a {{{UnicodeDecodeError}}} happens when _encoding_. The cause of it seems to be the encoding-specific {{{encode()}}} functions that normally expect a parameter of type {{{unicode}}}. It appears that on seeing an {{{str}}} parameter, the {{{encode()}}} functions "up-convert" it into {{{unicode}}} before applying its own encoding. It also appears that the "up-conversion" makes no assumption of {{{str}}} parameter's encoding, assuming it to be {{{ascii}}}. Hence a decoding failure inside an encoder. | Paradoxically, a {{{UnicodeDecodeError}}} happens when _encoding_. The cause of it seems to be the encoding-specific {{{encode()}}} functions that normally expect a parameter of type {{{unicode}}}. It appears that on seeing an {{{str}}} parameter, the {{{encode()}}} functions "up-convert" it into {{{unicode}}} before applying their own encoding. It also appears that the "up-conversion" makes no assumption of {{{str}}} parameter's encoding, assuming it to be {{{ascii}}}. Hence a decoding failure inside an encoder. |
Paradoxically, a UnicodeDecodeError happens when _encoding_. The cause of it seems to be the encoding-specific encode() functions that normally expect a parameter of type unicode. It appears that on seeing an str parameter, the encode() functions "up-convert" it into unicode before applying their own encoding. It also appears that the "up-conversion" makes no assumption of str parameter's encoding, assuming it to be ascii. Hence a decoding failure inside an encoder.