Re: odd unicode error



path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 1:
ordinal not in range(128)

Any ideas?

path is a Unicode string, b is a byte string and contains the
byte \xd0.

The problem is that you have a directory with file names in it that
cannot be converted to Unicode strings, using the file system
encoding. If you can't fix the file system, you have to make
search_path a byte string.

Regards,
Martin
.



Relevant Pages

  • Re: a question about unicode in python
    ... # s is a unicode string, ... UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1: ... by in python interactive, it is right ...
    (comp.lang.python)
  • encode() question
    ... UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position ... happens when you convert a regular string to a unicode string. ...
    (comp.lang.python)
  • Re: base64 and unicode
    ... Simpler than using the base64 module you can just use the base64 codec. ... This will decode a string to a byte sequence and you can then decode that ... to get the unicode string: ... python to close files for you is risky behaviour. ...
    (comp.lang.python)
  • Re: decode unicode string using unicode_escape codecs
    ... notation like '\n' for LF. ... I'm trying to use the builtin codec because I assume it has better performance that for me to write pure Python decoding. ... But I'm not converting between byte string and unicode string. ... UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 0: ordinal not in range ...
    (comp.lang.python)