I am working on a CPU emulator in Python, and I`m making a program to read ROM files.
The code that I have right now is:
ROMCHARS = []
ROMHEX = []
with open(RomPath, 'r') as f:
ROM = f.readline(1)
ROMCHARS = list(ROM)
for i in range(0, len(ROMCHARS)):
ROMHEX.append()
ROMHEX[i] = [Here the Code for Converting the UTF-16 Charater to Hex]
return ROMHEX
It converts each UTF-16 character into a hex code, puts it into a list, and returns the list.
The problem is that I haven’t figured out how to convert the characters to hexadecimal.
I already tried:
number = int('0030', base=16)
print(str(number))
But that just outputs nothing.