MCPcopy
hub / github.com/daviddrysdale/python-phonenumbers / u

Function u

python/phonenumbers/util.py:69–79  ·  view source on GitHub ↗

Generate Unicode string from a string input, encoding Unicode characters. This is expected to work in the same way as u' ' would work in Python 2.x (although it is not completely robust as it is based on a simple set of regexps).

(s)

Source from the content-addressed store, hash-verified

67 _U32_RE = re.compile(r'\\U(?P<hexval>[0-9a-fA-F]{8})')
68
69 def u(s):
70 """Generate Unicode string from a string input, encoding Unicode characters.
71
72 This is expected to work in the same way as u'<string>' would work in Python
73 2.x (although it is not completely robust as it is based on a simple set of
74 regexps).
75 """
76 us = re.sub(_U16_RE, lambda m: unichr(int(m.group('hexval'), 16)), unicode(s))
77 us = re.sub(_U32_RE, lambda m: unichr(int(m.group('hexval'), 16)), us)
78 us = re.sub(_UNAME_RE, lambda m: unicodedata.lookup(m.group('name')), us)
79 return us
80
81 to_long = long
82

Callers 15

_expand_formatting_ruleFunction · 0.90
__init__Method · 0.90
__unicode__Method · 0.90
__init__Method · 0.90
__unicode__Method · 0.90
__unicode__Method · 0.90
__unicode__Method · 0.90
__unicode__Method · 0.90
__unicode__Method · 0.90
testIsLatinLetterMethod · 0.90

Calls

no outgoing calls