title: parse hex file and decode byte by byte
body: <p>I have a hex file with extension .brt and having hex values in the range 00 - FF.
  I want to parse the file and print byte by byte value in the command prompt.</p>
  <p>I tried the below line of code:</p>
  <pre><code>file = open(&quot;file.brt&quot;, encoding='utf-8')
  data = file.read()
  </code></pre>
  <p>this gives me error as:</p>
  <pre><code>Exception has occurred: UnicodeDecodeError
  'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
  </code></pre>
  <p>I understand the error is because the value is more than 128. then i tried with utf-16, this gives some random value.
  then i have tried with the below line of code :</p>
  <pre><code>file = open(&quot;file.brt&quot;, encoding='ANSI')
  data = file.read()
  for line in data:
      for char in line:
          print(char.encode('utf-8').hex())
  </code></pre>
  <p>The above code is parsing the data but printing some random value if the hex value is more than <code>128</code>. for example if the hex value is <code>FF</code>, then it prints <code>c3bf</code></p>