X-Git-Url: https://git.korewanetadesu.com/?p=python-collate.git;a=blobdiff_plain;f=collate%2Ficu%2F__init__.py;h=5f3ec05f98f19d051c4c8a6beda8b14fc0968081;hp=6f9647e4141c3238e456a0acdd40a4057da81638;hb=9a7cf6459c40d53b58634f2df56386bf52c12f7c;hpb=2a37219e2d9c0fe58e78d987a21f6e37cfd33940 diff --git a/collate/icu/__init__.py b/collate/icu/__init__.py index 6f9647e..5f3ec05 100644 --- a/collate/icu/__init__.py +++ b/collate/icu/__init__.py @@ -37,9 +37,11 @@ class Collator(collate._abcollator.Collator): self._breaker = _icu.WordBreaker("root") def words(self, string): + """Split the string along word boundries.""" if isinstance(string, str): - string = string.decode(self.encoding, 'replace') - return filter(lambda u: not u.isspace(), self._breaker.words(string)) + string = string.decode(self.encoding) + words = self._breaker.words(string) + return [w for w in words if not w.isspace()] def key(self, string): """Sort key for a string.