Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 381
nEAnnam Avatar asked Jul 20 '11 22:07

nEAnnam


People also ask

What encoding is used in Notepad?

Files by default, are encoded in Notepad with either ANSI or UTF-8 (depending on the Notepad version). ANSI encoding generally is used for the Latin character set (including the English alphabet), and UTF-8 supports the Unicode character set (a global character set).

How can I tell the encoding of a file in Windows?

In Visual Studio, you can select "File > Advanced Save Options..." The "Encoding:" combo box will tell you specifically which encoding is currently being used for the file.

What is Windows character set?

A "character set" is a mapping of characters to their identifying code values. The character set most commonly used in computers today is Unicode, a global standard for character encoding. Internally, Windows applications use the UTF-16 implementation of Unicode.


1 Answers

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.

like image 121
Guffa Avatar answered Sep 19 '22 23:09

Guffa