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.