Skip to content

Commit fda40d1

Browse files
author
Bijan Chokoufe Nejad
committedSep 7, 2013
Added unicode support. Corresponding output with utf encoding is now necessary
1 parent 9a9b1a5 commit fda40d1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

Diff for: ‎calendar_parser.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ def _multi_replace(string, replace_dict):
6464
string = string.replace(str(key), str(value))
6565
return string
6666

67+
def to_unicode_or_bust(obj, encoding='utf-8'):
68+
if isinstance(obj, basestring):
69+
if not isinstance(obj, unicode):
70+
obj = unicode(obj, encoding)
71+
return obj
72+
6773
def _normalize(data_string, convert_whitespace=False):
6874
"Removes various markup artifacts and returns a normal python string."
69-
new_string = unescape(str(data_string))
75+
new_string = unescape(to_unicode_or_bust(data_string))
7076
new_string = _multi_replace(new_string, {
7177
' ': ' ', '"': '"', '¦': '|', "'": "'", "\\": ""
7278
})

0 commit comments

Comments
 (0)
Please sign in to comment.