On Wed, Jun 8, 2016 at 12:53 PM Alex Hall <ah...@autodist.com> wrote:

> All,
> I'm working on a project that writes CSV files, and I have to get it done
> very soon. I've done this before, but I'm suddenly hitting a problem with
> unicode conversions. I'm trying to write data, but getting the standard
> cannot encode character: ordinal not in range(128)
>

Have you tried ignoring invalid characters?

    >>> data = b'\x30\x40\xff\x50'
    >>> text = data.decode('utf-8')
    Traceback ... UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff
    >>> text = data.decode('utf-8', 'ignore')
    >>> print(text)
    0@P

BTW, most programming volunteers don't like responding to things marked
"Urgent". It's probably not really urgent unless someone's life is in
danger.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to