How windows notepad interpret characters

nEAnnam picture nEAnnam · Jul 21, 2011 · Viewed 21.2k times · Source

I was wondering how windows interpret characters, for instance:

I maked a file with an Hexeditor with the 3 bytes E3 81 81. Those bytes are the "ぁ" character encoded as UTF-8.

I open the notepad and it displays "ぁ"

I don't specified the encoding of the file, i just created the bytes. and the notepad interpret it correctly.

Is the notepad guessing what encoding probably is? or is the Hex editor saving those bytes with a specific encoding.

Answer

Guffa picture Guffa · Jul 21, 2011

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.