X-Git-Url: https://git.korewanetadesu.com/?p=python-collate.git;a=blobdiff_plain;f=collate%2Fsyslocale.py;fp=collate%2Fsyslocale.py;h=e48ee8252a86c89bab595c7a00c6d5418b8ad808;hp=5b8adcac87a22a5db3d815289d8d1880a7284163;hb=308778ae560a3258a55d578b1dd52d030ce4399d;hpb=f854c6958fd98bc3a1709e7aa1ede1ce7f5ab612 diff --git a/collate/syslocale.py b/collate/syslocale.py index 5b8adca..e48ee82 100644 --- a/collate/syslocale.py +++ b/collate/syslocale.py @@ -25,7 +25,6 @@ Avoid this backend if... __all__ = ["Collator"] import locale -import re import collate.errors import collate._abcollator @@ -54,12 +53,5 @@ class Collator(collate._abcollator.Collator): """ try: return locale.strxfrm(string) - except UnicodeEncodeError: - return locale.strxfrm(string.encode(self.encoding, "replace")) - - def words(self, string, sep=re.compile(r"\W+", re.UNICODE)): - """Split the string into separate words.""" - if isinstance(string, str): - string = string.decode(self.encoding, 'replace') - return re.split(sep, string) - + except UnicodeError: + return locale.strxfrm(string.str(self.encoding))