| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,6 +77,11 @@ def test_ascii(self): | |||
| 77 | 77 | ||
| 78 | 78 | wlog.stop() | |
| 79 | 79 | ||
| 80 | + def test_whitespace(self): | ||
| 81 | + self.assertEqual(" ", self.unidecode(_chr(0xa0))) | ||
| 82 | + self.assertEqual(" ", self.unidecode(_chr(0x2000))) | ||
| 83 | + self.assertEqual(" ", self.unidecode(_chr(0x3000))) | ||
| 84 | + | ||
| 80 | 85 | def test_bmp(self): | |
| 81 | 86 | for n in range(0,0x10000): | |
| 82 | 87 | # skip over surrogate pairs, which throw a warning | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,7 @@ | |||
| 16 | 16 | """ | |
| 17 | 17 | import warnings | |
| 18 | 18 | from sys import version_info | |
| 19 | + import re | ||
| 19 | 20 | ||
| 20 | 21 | Cache = {} | |
| 21 | 22 | ||
@@ -74,10 +75,14 @@ def _unidecode(string): | |||
| 74 | 75 | if codepoint < 0x80: # Basic ASCII | |
| 75 | 76 | retval.append(str(char)) | |
| 76 | 77 | continue | |
| 77 | - | ||
| 78 | + | ||
| 78 | 79 | if codepoint > 0xeffff: | |
| 79 | 80 | continue # Characters in Private Use Area and above are ignored | |
| 80 | 81 | ||
| 82 | + if re.match(r"\s",char,re.UNICODE): | ||
| 83 | + retval.append(" ") | ||
| 84 | + continue | ||
| 85 | + | ||
| 81 | 86 | if 0xd800 <= codepoint <= 0xdfff: | |
| 82 | 87 | warnings.warn( "Surrogate character %r will be ignored. " | |
| 83 | 88 | "You might be using a narrow Python build." % (char,), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments