INTRODUCING ensure_utf8_string, use it to fix BLOCKER bug for Gajim/Windows (#2392)

This commit is contained in:
Nikos Kouremenos 2006-09-06 13:28:38 +00:00
parent 9bd4442784
commit bd01e5719b
2 changed files with 13 additions and 3 deletions

View File

@ -534,6 +534,14 @@ def decode_string(string):
return string
def ensure_utf8_string(string):
'''make sure string is in UTF-8'''
try:
string = decode_string(string).encode('utf-8')
except:
pass
return string
def get_windows_reg_env(varname, default=''):
'''asks for paths commonly used but not exposed as ENVs
in english Windows 2003 those are:

View File

@ -681,9 +681,11 @@ class ConversationTextview:
if day_str:
format += day_str + ' '
format += '%X' + after_str
# format comes as unicode, because of day_str.
# we convert it to the encoding that we want
tim_format = time.strftime(format, tim).encode('utf-8')
tim_format = time.strftime(format, tim)
# if format comes as unicode because of day_str.
# we convert it to the encoding that we want (and that is utf-8)
tim_format = helpers.ensure_utf8_string(tim_format)
tim_format = tim_format.encode('utf-8')
buffer.insert_with_tags_by_name(end_iter, tim_format + ' ',
*other_tags_for_time)
elif current_print_time == 'sometimes' and kind != 'info':