On Tue, Jan 19, 2010 at 8:16 PM, Gnarlodious <gnarlodi...@gmail.com> wrote:
> Well, Python 3 is supposed to be all Unicode by default. I shouldn't > even need to say > # coding:UTF-8 > > And, the file is saved as Unicode. > > There are many mentions of this error found by Google, but none seen > to clearly say what the problem is or how to fix it. > > FYI, the problem line says: > > cursor.execute('insert into Data values > (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', frameTuple) > > and one of the strings in the tuple contains a character like 'ñ'. > I have a version of the SQLite editor that works as expected in a > browser, I don't know why. > > But is it a -unicode- string, or a -byte- string? Print it with repr(). By that error, it seems like its a bytestring. So you read it or got it from a source which provided it to you not as unicode. In that case, find out what the encoding is-- and decode it. after = before.decode("utf8") Python 3 is not 'all unicode'; or 'by default'. Python 3 has a firm line in the sand. Everything is either explicitly a byte string (bytes) or explicitly a unicode string (str). --S
-- http://mail.python.org/mailman/listinfo/python-list