On Tue, Jan 19, 2010 at 8:16 PM, Gnarlodious <span dir="ltr"><<a href="mailto:gnarlodious@gmail.com">gnarlodious@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Well, Python 3 is supposed to be all Unicode by default. I shouldn't<br>
even need to say<br>
# coding:UTF-8<br>
<br>
And, the file is saved as Unicode.<br>
<br>
There are many mentions of this error found by Google, but none seen<br>
to clearly say what the problem is or how to fix it.<br>
<br>
FYI, the problem line says:<br>
<br>
cursor.execute('insert into Data values<br>
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', frameTuple)<br>
<br>
and one of the strings in the tuple contains a character like 'ñ'.<br>
I have a version of the SQLite editor that works as expected in a<br>
browser, I don't know why.<br>
<div><div></div><div class="h5"><br></div></div></blockquote><div><br></div><div>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.</div>
<div><br></div><div>after = before.decode("utf8")</div><div><br></div><div>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).</div>
<div> </div></div><div name="mailplane_signature">--S</div>