commit 6b3e556ced2fe137360ad87870a8a0419329f20b
parent 2708c23009a6928a655ec724566ddd70a4358e98
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Sat, 26 Oct 2013 12:55:03 +0200
work around unicode problems -- should move everything to python3...
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/common.py b/common.py
@@ -26,6 +26,8 @@ def strip_accents_one(s, with_except=False):
with_except keeps specifically 'é' and 'è'"""
r = []
for x in s:
+ if isinstance(x, str):
+ x = x.decode('utf-8')
if with_except and x in ['è', 'é']:
r.append(x)
else:
@@ -57,6 +59,8 @@ def is_vowels(chunk, with_h=False, with_y=True):
if not with_y and chunk == 'y':
return False
for char in strip_accents(chunk):
+ if isinstance(char, unicode):
+ char = char.encode('utf-8')
if char not in vowels:
if char != 'h' or not with_h:
return False
@@ -66,6 +70,8 @@ def is_consonants(chunk):
"""Test if a chunk is consonants"""
for char in strip_accents(chunk):
+ if isinstance(char, unicode):
+ char = char.encode('utf-8')
if char not in consonants:
return False
return True