python如何代替javascript
October 17th, 2008 Encoding is always a problem。 We use the utf8 encoding as a best practise to get around this。 The bad news is, in the web development, the problem gets more complicated。 Because HTTP, the foundamental protocol the whole internet is built on, doesn’t support non-ascii cha...全部
October 17th, 2008 Encoding is always a problem。 We use the utf8 encoding as a best practise to get around this。
The bad news is, in the web development, the problem gets more complicated。 Because HTTP, the foundamental protocol the whole internet is built on, doesn’t support non-ascii characters。
In fact, the stupid HTTP can only handle 7-bit characters。For the most obvious reason, we invented escape and unescape in client side script。
Nowadays escape()/unescape() is seen in all modern Javascript implementations。 And they are able to handle different encodings correctly。
For example:escape("记性") will give us "%u8BB0%u6027" and we'll get "记性" back by unescape("%u8BB0%u6027")。
The above example supposed that the string “记性” is oringally in utf-8 encoding。 It works in IE6/IE7, Firefox, Google Chrome and etc。
Give it a try!The result of escape is 7-bit characters, that is escaped string can transfer safely through HTTP without any problem。
There is still problems because most of us don’t write our server in javascript。 unescape() does not exist in any language except javascript of course。
You may have seen functions or methods with the same or similar name in some library or module。
But as far as I know, none of these functions in the same way as the one does in javascript。 Can we create one? of course! what is a programmer for?。
收起