windowsencodingutf-8notepadhex-editors

How does Windows Notepad interpret characters?


I was wondering how Windows interprets characters.

I made a file with a hex editor with the 3 bytes E3 81 81.
Those bytes are the character in UTF-8.

I opened the notepad and it displayed . I didn't specify the encoding of the file, I just created the bytes and the notepad interpreted it correctly.

Is notepad somehow guessing the encoding?
Or is the hex editor saving those bytes with a specific encoding?


Solution

  • If the file only contains these three bytes, then there is no information at all about which encoding to use.

    A byte is just a byte, and there is no way to include any encoding information in it. Besides, the hex editor doesn't even know that you intended to decode the data as text.

    Notepad normally uses ANSI encoding, so if it reads the file as UTF-8 then it has to guess the encoding based on the data in the file.

    If you save a file as UTF-8, Notepad will put the BOM (byte order mark) EF BB BF at the beginning of the file.