mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
DBManager: fix data conversion to unicode (errors='replace' should be enough)
This commit is contained in:
parent
a7cd1985ed
commit
401f43c590
@ -75,11 +75,8 @@ class BaseTableModel(QAbstractTableModel):
|
|||||||
return None
|
return None
|
||||||
elif isinstance(val, (str, unicode)) and len(val) > 300:
|
elif isinstance(val, (str, unicode)) and len(val) > 300:
|
||||||
# too much data to display, elide the string
|
# too much data to display, elide the string
|
||||||
return u"%s..." % val[:300]
|
val = val[:300]
|
||||||
try:
|
return unicode(val, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)
|
||||||
return unicode(val) # convert to unicode
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
return unicode(val, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)
|
|
||||||
|
|
||||||
|
|
||||||
def headerData(self, section, orientation, role):
|
def headerData(self, section, orientation, role):
|
||||||
|
@ -37,10 +37,7 @@ class BaseError(Exception):
|
|||||||
else:
|
else:
|
||||||
msg = e
|
msg = e
|
||||||
|
|
||||||
try:
|
msg = unicode(msg, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)
|
||||||
msg = unicode(msg) # convert to unicode
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
msg = unicode(msg, 'utf-8', 'replace') # convert from utf8 and replace errors (if any)
|
|
||||||
|
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
Exception.__init__(self, msg)
|
Exception.__init__(self, msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user