(matchobj: re.Match[str])
| 46 | """ |
| 47 | |
| 48 | def repl(matchobj: re.Match[str]) -> str: |
| 49 | i = ord(matchobj.group()) |
| 50 | if i <= 0xFF: |
| 51 | return f"#x{i:02X}" |
| 52 | else: |
| 53 | return f"#x{i:04X}" |
| 54 | |
| 55 | # The spec range of valid chars is: |
| 56 | # Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] |