0

It is a Mathematical Alphanumeric Symbols ( capital D ) and I just want to convert into simple English letter ( Capital D ).

Like, \U0001d403 => \uxxxx.

I am not familiar with decode-encoding mechanism.

Is there any conversion way ?

3
  • Could you maybe further clarify your question. since running print('\U0001d403') gives the Capital D Commented Jun 4, 2021 at 13:32
  • The escape sequence is only useful in string literals. If you already have a str value, you probably just want a new string with the correct character already in it. Commented Jun 4, 2021 at 13:34
  • If you are looking for a way to convert this symbol into a normal capital D, you can do import unicodedata and then unicodedata.normalize('NFKC', '\U0001d403') results in 'D'. Commented Jun 4, 2021 at 13:37

1 Answer 1

2

If nothing else, you can build your own map for the string translation: for example:

>>> x = '\U0001d403' >>> x '𝐃' >>> x.translate(str.maketrans({'\U0001d403': 'D'})) 'D' 

maketrans can create a mapping of multiple characters, which can be saved to be reused as an argument for many calls to str.translate. Note also that str.translate works for arbitrary strings; the given map will be applied to each character separately.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.