UnicodeDecodeError, how to elegantly deal with this?

John Machin sjmachin at lexicon.net
Tue Aug 5 07:25:34 EDT 2008


On Aug 5, 8:37 pm, "Jorgen Bodde" <jorgen.maill... at gmail.com> wrote:
> Hi John,
>
> > If you don't want to be bothered with "unicode problems":
> > (1) Don't create a "unicode problem" when one doesn't exist.
> > (2) Don't bother other people with *your* "unicode problems".
>
> Well I guess you misunderstood what I meant.

Sorry, it's my ETL (English as a Third Language) problem; my mother
tongue is the Queensland dialect of Australian :-)

>
> > In this case, less is more; remove the u prefix in the line
> >    filemask = u"%file%"
>
> Ok thanks. I thought making it unicode because it is a search string
> that is used in a UTF-8 encoded replacement, would solve it,

"UTF-8 encoded" implies a str (8-bits per character) object, not a
unicode object. Solve what? What problem did you have before you put
the u in there?

>
> > Long Path:
> > Ignorance is not bliss. Lose the attitude. Unicode is your friend, not
> > an instrument of Satan. Read this:
> >    http://www.amk.ca/python/howto/unicode
>
> I never said that I have an attitude towards unicode, I simply
> misunderstood it's inner workings.

I must have misunderstood "pains" and "bother", eh?

Cheers,
John



More information about the Python-list mailing list