Converts string to Unicode code point ('263A' => 0x263a). Args: s: string to convert Returns: Unicode code point Raises: InputError: the string is not a valid Unicode value.
(s)
| 28 | |
| 29 | |
| 30 | def _UInt(s): |
| 31 | """Converts string to Unicode code point ('263A' => 0x263a). |
| 32 | |
| 33 | Args: |
| 34 | s: string to convert |
| 35 | |
| 36 | Returns: |
| 37 | Unicode code point |
| 38 | |
| 39 | Raises: |
| 40 | InputError: the string is not a valid Unicode value. |
| 41 | """ |
| 42 | |
| 43 | try: |
| 44 | v = int(s, 16) |
| 45 | except ValueError: |
| 46 | v = -1 |
| 47 | if len(s) < 4 or len(s) > 6 or v < 0 or v > _RUNE_MAX: |
| 48 | raise InputError("invalid Unicode value %s" % (s,)) |
| 49 | return v |
| 50 | |
| 51 | |
| 52 | def _URange(s): |
no test coverage detected