Windows notepad bug explanation

Source: Internet
Author: User
My explanation of Windows notepad bug

This bug is used in both Windows XP SP1 and SP2. I have not tried it in other versions of Windows, But I guess Windows 2003 and both exist.

Bug Demo:
Create a new text in Notepad. After the text is opened, enter the words "China Unicom", save the text, and close notepad.

Open it again. What have you seen?

One joke is that China Unicom has offended Microsoft China ......

In fact, I think Microsoft's Chinese team is not good at the level, which is caused by poor multi-language coding.

I analyzed the reason,
When notepad is saved, ANSI encoding is used by default.
But it is encoded in ANSI. The beginning of the word "Unicom" is exactly fffe ..... in this case, he thought it was UTF-8 encoding, but it was decoded according to UTF-8, but it caused garbled characters.

Are you satisfied with the explanation?

The reason why I want to explain this bug is that a software developed recently involves coding issues, the Microsoft Windows bug makes it impossible for my software-generated files to be transplanted to other platforms.

Haha

Shinzeal PM
I will analyze it in detail:
The following is the hexadecimal code of China Unicom in different codes:

FF Fe 54 80 1A 90 (UNICODE)
Fe FF 80 54 90 1A (big Unicode)
FF Fe 54 80 1A 90 (UTF-8)
FF Fe 6a 00 68 03 (ANSI)

It can be seen that, Unicode and UTF-8 encoding, Unicom two character encoding is the same, and big Unicode is and little Unicode (UNICODE) exactly the opposite of the encoding method, generally, Intel systems use little unicode encoding for computers with high efficiency. The file header FF Fe AND Fe FF are used by Microsoft to identify whether a file is little Unicode or big Unicode. At the same time, because the UTF-8 is also due to the Unicode encoding method, Microsoft added FF Fe in front of the UTF-8 encoding file is used as a sign.

In this case, the files stored in ANSI encoding become faulty, because the ANSI encoding of Unicom is just starting with fffe, which will be opened again after being saved in ANSI encoding, notepad first detected fffe, it is considered to be UTF-8 encoding, so according to the UTF-8 encoding after opening will display as garbled.

By using this principle, you can try to find other texts starting with fffe in ANSI encoding, which can also achieve the same effect as the bug caused by Unicom in notepad.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.