ISO-8859-1 garbled recovery, iso-8859-1 garbled

Source: Internet
Author: User

ISO-8859-1 garbled recovery, iso-8859-1 garbled

To be compatible with older jQuery plug-ins, I reduced the jQuery version from 2.1.x to 1.8.x, which is easier than adding the jquery-migration plug-in.

I did not remember the differences between the two versions, but changed them directly. If no error is reported on the page after the downgrade, I think it is okay. It was not until one day that many users in the database generated garbled content.

After some debugging, the cause is found: the http method used by jQuery ajax is specified with option type before 1.9.0, and later with Option method (option type is the alias of method:

//from jquery 1.9.0jQuery.ajax("/action",{    method:"POST"});
//before jquery 1.9.0jQuery.ajax("/action",{    type:"POST"});

When the jQuery version is reduced from 2.1.x to 1.8.x, the following code hides a bug, which does not report an error but is fatal:

jQuery.ajax("/action",{    method:"POST" //buggy});

The reason is that jQuery 1.8.x does not recognize the option method, which means that the final http method that jQuery decides to use will be the default "GET"

In case of garbled characters, you may first determine whether there is any problem with the server's character decoding, even if the server's character decoding settings have been applied stably in many other projects.

If the bug is revealed, kill it. However, during this period, many users in the database generated garbled data due to bugs. What should I do if I admit technical mistakes and apologize to the users?

A long time ago, I heard that some software can restore Garbled text to normal text. This shows that recovery is still promising. It is known that garbled characters are caused by the absence of URI decoding. Therefore, After decoding, the data should be restored to normal text. According to this idea, I copied the garbled content for a test:

decodeURIComponent(escape("一直想买一个,å¯æƒœæ²¡æœ‰ç±³å•Š•Š"))

The normal text can be restored!
So I wrote a small program, found out the garbled content from the database, restored it to normal text, and finally written it back to the database.

Sometimes downgrading is not just as simple as changing the version number, but some code must be adjusted along with synchronization.

Copyright Disclaimer: This article is the original flashdelover article. Do not repost it without permission!

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.