1

I need to print a range of unicode characters given in hex.

range = "<range first-cp="0030" last-cp="0039"/>"

I need to write a code in python, that takes this string range as input and prints all the code points in the range 0030 to 0039. I have come to know that I will need to convert each code point to an int first then increment it and convert it back to a hex string. For example, if

first_cp = "0030"
second_cp = int(first_cp, 16) + 1  # converts it to an integer and increments it
second_cp = hex(second_cp)  # returns '0x31'    

Here, I don't know how can I convert the integer back to a hex string such that it has the format 0031 instead of 0x31. Please note that I do not want to remove 0x from the string only.

0 Answers0