Skip to content

Commit 037c426

Browse files
committed
Add comments, clarify doctest for unicode_utils.py
1 parent 9f362e2 commit 037c426

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

python/phonenumbers/unicode_util.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
'Lu'
1616
>>> unicode_util.Category.get(u2) == unicode_util.Category.LOWERCASE_LETTER
1717
True
18-
>>> beyond_bmp = u'\U00010100'
18+
>>> beyond_bmp = u'\U00010100' # AEGEAN WORD SEPARATOR LINE
1919
>>> if len(beyond_bmp) == 1: # We have a UCS4 build of Python
2020
... unicode_util.Category.get(beyond_bmp)
21-
... else: # UCS2 build of Python; no unknown characters available
22-
... 'Po'
21+
... else: # UCS2 build of Python; no non-BMP chars available
22+
... unicode_util.Category.OTHER_PUNCTUATION
2323
'Po'
2424
>>> unicode_util.is_letter(u1)
2525
False
@@ -67,6 +67,9 @@
6767

6868

6969
class Category(object):
70+
"""General category of a Unicode character.
71+
72+
See http://www.unicode.org/reports/tr18/#Categories"""
7073
LETTER = "L"
7174
UPPERCASE_LETTER = "Lu"
7275
LOWERCASE_LETTER = "Ll"
@@ -107,6 +110,7 @@ class Category(object):
107110

108111
@classmethod
109112
def get(cls, unichr):
113+
"""Return the general category code for the given Unicode character"""
110114
unichr = unicode(unichr)
111115
return unicodedata.category(unichr)
112116

0 commit comments

Comments
 (0)