Add new encoder
This encoder is used to handle input from HH conversion, which needs to end up as UTF-8 in the database. Switch the open-coded routine from Database.py to this common routine so all encodings now take place in the same file.
This commit is contained in:
@@ -40,6 +40,16 @@ def to_utf8(s):
|
||||
print 'Could not convert: "%s"' % s
|
||||
raise
|
||||
|
||||
def to_db_utf8(s):
|
||||
if not_needed: return s
|
||||
|
||||
try:
|
||||
(_out, _len) = encoder_to_utf.encode(unicode(s))
|
||||
return _out
|
||||
except UnicodeDecodeError:
|
||||
print 'Could not convert: "%s"' % s
|
||||
raise
|
||||
|
||||
def to_gui(s):
|
||||
if not_needed: return s
|
||||
|
||||
|
||||
Reference in New Issue
Block a user