asif1268
asif1268

Reputation: 185

How to get UTF-16 numeric value of a characters in python?

My goal is something like this

Input:

"ABC"

Output:

[0x0041, 0x0042, 0x0043]

The outputs are corrosponding UTF-16 value of each character. How do I get the numeric(BIN/HEX/DEC) UTF-16 value from a string or single character?

Upvotes: 0

Views: 234

Answers (1)

Hasan Aga
Hasan Aga

Reputation: 774

for Python 3, you can do that as follows:

for i in "ABC":
    print(hex(ord(i)))

0x41 0x42 0x43

Upvotes: 1

Related Questions