Skip to content

GH-96172 fix unicodedata.east_asian_width being wrong on unassigned code points #96207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
GH-96172 unicodedata: fix wrong default for east_asian_width
also return the correct width for unassigned but reserved characters
according to EastAsianWidth.txt
  • Loading branch information
cfbolz committed Aug 23, 2022
commit 5688e6afe15f60d93bc45c275bcd099482ca006b
12 changes: 12 additions & 0 deletions Lib/test/test_unicodedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@ def test_east_asian_width(self):
self.assertEqual(eaw('\u2010'), 'A')
self.assertEqual(eaw('\U00020000'), 'W')

def test_east_asian_width_unassigned(self):
eaw = self.db.east_asian_width
# unassigned
for char in '\u0530\u0ece\u10c6\u20fc\uaaca\U000107bd\U000115f2':
self.assertEqual(eaw(char), 'N')
self.assertIs(self.db.name(char, None), None)

# unassigned but reserved
for char in '\uFA6E\uFADA\U0002A6E0\U0002FA20\U0003134B\U0003FFFD':
self.assertEqual(eaw(char), 'W')
self.assertIs(self.db.name(char, None), None)

def test_east_asian_width_9_0_changes(self):
self.assertEqual(self.db.ucd_3_2_0.east_asian_width('\u231a'), 'N')
self.assertEqual(self.db.east_asian_width('\u231a'), 'W')
Expand Down
Loading