sqlite utf8编码错误 [英] sqlite utf8 encoding error
问题描述
我有一个使用sqlite3来存储作业/错误数据的应用程序。当
我以德国用户身份登录时,生成的错误代码将转换为
德语。然后将错误代码文本存储在db中。当我使用
fetchall()来检索数据以生成报告时,我得到
以下错误:
Traceback (最近一次打电话):
文件" c:\Pest3 \ Gllosser\baseApp\reportGen.py",第199行,
OnGenerateButtonNow
self.OnGenerateButton(事件)
文件" c:\Pest3\Glosser\baseApp\reportGen.py",第243行,
OnGenerateButton
warningresult = messagecursor1.fetchall()
UnicodeDecodeError:''utf8''编解码器无法解码13-18位的字节:
不支持的Unicode代码范围
有没有人知道可能出现什么问题?我存储在数据库表中的字符串
是:
''KeinenTextfürübereinstimmungsfehlergefunden''
我以为所有的字符串都存储在sqlite的unicode中。
Greg Miller
Greg Miller写道:
UnicodeDecodeError:''utf8''编解码器无法解码13-18位的字节:
不支持的Unicode代码范围>
有没有人知道可能出现什么问题?我存储在数据库表中的字符串是:
''KeinenTextfürübereinstimmungsfehlergefunden''
更多test.py
# - * - 编码:iso-8859-1 - * -
u = u''KeinenTextfürübereinstimmungsfehlergefunden''
s = u.encode(" iso-8859-1")
u = s.decode(" utf-8")#< - 这会给出错误>
python test.py
Traceback(最近一次调用最后一次):
文件test.py ;,第4行,在?
u = s.decode(" utf-8")#< - 这会给出错误
文件" lib / encodings / utf_8.py",第16行,在解码中
返回codecs.utf_8_decode(输入,错误,真)
UnicodeDecodeError:''utf8''编解码器不能解码位置13-18中的字节:
不支持的Unicode代码范围
我认为所有字符串都存储在sqlite中的unicode中。
在存储文本时是否传递了Unicode字符串或8位字符串?
< / F>
I have an application that uses sqlite3 to store job/error data. When
I log in as a German user the error codes generated are translated into
German. The error code text is then stored in the db. When I use the
fetchall() to retrieve the data to generate a report I get the
following error:
Traceback (most recent call last):
File "c:\Pest3\Glosser\baseApp\reportGen.py", line 199, in
OnGenerateButtonNow
self.OnGenerateButton(event)
File "c:\Pest3\Glosser\baseApp\reportGen.py", line 243, in
OnGenerateButton
warningresult = messagecursor1.fetchall()
UnicodeDecodeError: ''utf8'' codec can''t decode bytes in position 13-18:
unsupported Unicode code range
does anyone have any idea on what could be going wrong? The string
that I store in the database table is:
''Keinen Text für übereinstimmungsfehler gefunden''
I thought that all strings were stored in unicode in sqlite.
Greg Miller
Greg Miller wrote:
UnicodeDecodeError: ''utf8'' codec can''t decode bytes in position 13-18:
unsupported Unicode code range
does anyone have any idea on what could be going wrong? The string
that I store in the database table is:
''Keinen Text für übereinstimmungsfehler gefunden''
more test.py
# -*- coding: iso-8859-1 -*-
u = u''Keinen Text für übereinstimmungsfehler gefunden''
s = u.encode("iso-8859-1")
u = s.decode("utf-8") # <-- this gives an error
python test.py
Traceback (most recent call last):
File "test.py", line 4, in ?
u = s.decode("utf-8") # <-- this gives an error
File "lib/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: ''utf8'' codec can''t decode bytes in position 13-18:
unsupported Unicode code range
I thought that all strings were stored in unicode in sqlite.
did you pass in a Unicode string or an 8-bit string when you stored the text ?
</F>
这篇关于sqlite utf8编码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!