[FIX] unicode proble.

lp bug: https://launchpad.net/bugs/327294 fixed

bzr revid: ame@tinyerp.com-20090212133252-wludmq0d95irp6dm
This commit is contained in:
ame (Tiny/Axelor) 2009-02-12 19:02:52 +05:30
parent 86fad5a90e
commit b850cfe3e5
2 changed files with 13 additions and 9 deletions

View File

@ -155,12 +155,8 @@ class char(_column):
# we need to convert the string to a unicode object to be able
# to evaluate its length (and possibly truncate it) reliably
if isinstance(symb, str):
u_symb = unicode(symb, 'utf8')
elif isinstance(symb, unicode):
u_symb = symb
else:
u_symb = unicode(symb)
u_symb = tools.ustr(symb)
return u_symb[:self.size].encode('utf8')

View File

@ -677,11 +677,19 @@ def ustr(value):
if not isinstance(value, str):
value = str(value)
try:
try: # first try utf-8
return unicode(value, 'utf-8')
except:
from locale import getlocale
return unicode(value, getlocale()[1])
pass
try: # then extened iso-8858
return unicode(value, 'iso-8859-15')
except:
pass
# else use default system locale
from locale import getlocale
return unicode(value, getlocale()[1])
def exception_to_unicode(e):
if hasattr(e, 'message'):