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:
Mika Bostrom
2010-01-24 21:11:46 +02:00
parent 6dcec48005
commit 33277ce68b
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -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