I am trying to program a hex-viewer for cmd in python 2.7
It works almost fine, but if I try to view a compiled file on windows, it shows only a little part of it. I already figured out, that read() breaks at the first occurrence of 0x1a (in ASCII). Notepad++ shows this char as SUB. I don't know what this control-character does, why read() stops at this char and how to avoid this break. Can anyone help me?
Here's my whole code:
def main():
while True:
print "Enter a file path:"
path = raw_input()
f = open(path, 'r')
text = f.read() # seems to break at 0x1a/SUB
f.close()
for c in text:
hex_c = hex(ord(c))[2:]
if len(hex_c) % 2: # if the hex number consists of 1 digit
hex_c = '0' + hex_c # fill the string with a zero
print hex_c,
print # just as a line break in the console
if __name__ == '__main__':
main()