The difference between ascii160 and ASCII32

Source: Internet
Author: User
Long time no write something, too busy to write. But today I had a problem, a headache for a while, but fortunately, eventually find the problem, feeling this problem still some of the necessary, in Baidu to check a lot about this keyword, have not found, only in Google to find some simple, so want to record this, a total share.

It is known that an ASCII code corresponds to a character, such as ASCII code 97, which means a (note is lowercase), but usually it is rarely noticed that there are even spaces (space) in the ASCII code, ASCII code 32, and ASCII code 160. So this two represents the difference between a space.

To say that they are not, in fact, is mainly in IE and Firefox differences, said more, or through a simple example to explain the problem more directly when. Today encountered a bug, the previous run when there is no problem, are upgraded after the problem, my code has not changed.

There's a piece of code that returns a value from someone else's JavaScript code and then judges this:

if (Attrbmctype = = "Early Commit") {}

In this simple judgment, normally, Attrbmctype will return "Early Commit", if the condition should be true, in the Firefox test when there is no problem, but in order to use IE test when the new problem, alert (attrbmctype , found in Firefox normal display, but in IE shows "Earlylcommit", Strange, the space ran there. The principle is the trouble with the ASCII code.

Let's do another experiment. In Javascipt, the String.fromCharCode () method returns a string based on Unicode characters (which is also searched on the internet for a long time), and we use this method to see what is there.

var test = String.fromCharCode (112, 160, 108, 97, 32, 105, 110);

The same JavaScript code, which returns "P LA in" to Firefox, but returns "PLA in" from IE, I think you've seen the difference here. Then look up the ASCII code table, will find that ascii160 and ascii32 are space, but in IE, 160 is not the display of space, Firefox will show space, 32 whether it is Firefox, or IE in the display of space.

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.