[Solved] ASCII to binary conversion?


È is not an ASCII character. Let’s assume the file is actually encoded using cp1252[1].

È encoded using cp1252 is C8 (hex).

If you interpret C8 as an unsigned 8-bit integer, it’s 200.

If you interpret C8 as a signed 8-bit integer, it’s -56.

If you interpret C8 as a signed 8-bit integer, then extend it to a signed 32-bit integer, then cast it to an unsigned 32-bit integer, it’s 4294967240.

So you have the expected value; you are simply interpreting it differently than you intended.


  1. The encoding used to make systems calls (the encoding of LPCTSTR and LPTSTR arguments to system calls) in a build where UNICODE isn’t defined is called the “ANSI” encoding. The actual encoding can vary from machine to machine. However, the “ANSI” encoding for (most? all?) English-language Windows machines is cp1252.

3

solved ASCII to binary conversion?