I\'d like to convert some character into five digit unicode on in Python 3.3. For example,
import re
print(re.sub(\'a\', u\'\\u1D15D\', \'abc\' ))
By the way, you do not need the re
module for this. You could use str.translate:
>>> 'abc'.translate({ord('a'):'\U0001D15D'})
'
Python unicode escapes either are 4 hex digits (\uabcd) or 8 (\Uabcdabcd); for a codepoint beyond U+FFFF you need to use the latter (a capital U), make sure to left-fill with enough zeros:
>>> '\U0001D15D'
'