On Sunday, July 29, 2007 10:39 PM, Question wrote: > That's uri_escape() function in the URI::Escape module, sorry for > the clerical error. :-)
> To others: > I just found the escape & unescape in the URI::Escape module. > It seems escape & unescape are not recommended ones, also the > escape function does not work the same as encodeURIComponent > does. See the reference: > MSDN JScript Reference: The escape method returns a string value (in > Unicode format) that contains the contents of [the argument]. All > spaces, punctuation, accented characters, and any other non-ASCII > characters are replaced with %xx encoding, where xx is equivalent to > the hexadecimal number representing the character. For example, a > space is returned as "%20." > Edge Core Javascript Guide: The escape and unescape functions let > you encode and decode strings. The escape function returns the > hexadecimal encoding of an argument in the ISO Latin character > set. The unescape function returns the ASCII string for the > specified hexadecimal encoding value. > MSDN JScript Reference: The encodeURI method returns an encoded > URI. If you pass the result to decodeURI, the original string is > returned. The encodeURI method does not encode the following > characters: ":", "/", ";", and "?". Use encodeURIComponent to encode > these characters. Edge Core Javascript Guide: Encodes a Uniform > Resource Identifier (URI) by replacing each instance of certain > characters by one, two, or three escape sequences representing the > UTF-8 encoding of the character > MSDN JScript Reference: The encodeURIComponent method returns an > encoded URI. If you pass the result to decodeURIComponent, the > original string is returned. Because the encodeURIComponent method > encodes all characters, be careful if the string represents a path > such as /folder1/folder2/default.html. The slash characters will be > encoded and will not be valid if sent as a request to a web > server. Use the encodeURI method if the string contains more than a > single URI component. Mozilla Developer Core Javascript Guide? > Encodes a Uniform Resource Identifier (URI) component by replacing > each instance of certain characters by one, two, or three escape > sequences representing the UTF-8 encoding of the character. > So, I think escape will not encode 69 characters : > *?+?-?.?/[EMAIL PROTECTED] > encodeURI will not encode 82 characters : > !?#?$?&?'?(?)?*?+?,?-?.?/?:?;[EMAIL PROTECTED] > encodeURIComponent will not encode 71 characters : !? > '?(?)?*?-?.?_?~?0-9?a-z?A-Z > They are not the same. > Now, my solution is make a js file with a encoded string as STDIN, > decoded string as STDOUT which will be called by $string = `cscript > decode.js $string`; and cmd window will flash. That's a stupid > design in my mind. Oops... I don't see the problem. The uri_escape function from URI::Encode lets you choose which characters to encode, and it handles utf8 encoding. So you can make it behave like any of the js functions you mention. What else could you need? Eric _______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs