[Zope] url_quote and "javascript quote"

Dieter Maurer dieter@handshake.de
Sat, 30 Mar 2002 22:03:48 +0100


iap@y2fun.com writes:
 > ...
 > The problem is that I can't pass binary string from server by "url_quote"
 > and decode it in the broswer by "unescape".
 > 
 > My questions:
 > 1) Is there any zope object can  be used to encode string in "javascript"
 > way in the server side?
Python's and JavaScript's quoting rules for strings are similar.
Therefore, "repr" may be sufficient.

 > 2) Or I missed something that  there is function of javascript which can
 > decode "url_quote" string in the client side?
When you know that a string is generated for Javascript interpretation,
why do you want to "url_quote" it?

While the old URL standard specified that each non-ascii latin-1 character is
replaced by "%XX" where "XX" are the two hex digits representing the
character code (this obviously is insufficient for non-western languages),
the new standard recommends to first encode the string as UTF-8
and then apply the old URL encoding to the resulting sequence of bytes.
It may well be that the Javascript "unescape" expects this coding.


Dieter