Py 3: How to switch application to Unicode strings?

Mark Tolonen metolone+gmane at gmail.com
Tue Jan 19 22:34:12 EST 2010


"Stephen Hansen" <apt.shansen at gmail.com> wrote in message 
news:7a9c25c21001191156j46a7fdadt58b728477b85e651 at mail.gmail.com...
> On Tue, Jan 19, 2010 at 7:50 AM, Gnarlodious <gnarlodious at gmail.com> 
> wrote:
>
>> I am using Python 3, getting an error from SQLite:
>>
>> sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless
>> you use a text_factory that can interpret 8-bit bytestrings (like
>> text_factory = str). It is highly recommended that you instead just
>> switch your application to Unicode strings.
>>
>> So... how do I switch to Unicode? I thought I was doing it when I put
>
> # coding:utf-8
>>
>> at the start of my script.
>>
>
> All that does is mean that the script itself is encoded as utf8.
>

Actually it means that the user has declared that the source file is encoded 
in utf-8.  A common source of errors is that the source file is *not* 
encoded in utf-8.  Make sure to save the source file in the encoding 
declared.

-Mark 





More information about the Python-list mailing list