[Web-SIG] JavaScript escape function

Donovan Preston dp at ulaluma.com
Tue Apr 26 06:41:27 CEST 2005


On Apr 25, 2005, at 9:23 PM, Rene Dudfield wrote:

> repr works quite well, and I've used it with lots of different
> javascript... However I'm not completely confident in it as it fails
> for unicode.

Ah, unicode, yes. Nevow handles unicode at a different abstraction  
level, in the main flatten loop, nevow.flat.ten.iterflatten. It  
encodes to utf-8 by default.

Nevow's flattening process does a very good job of ensuring the right  
quoting takes place in the right context. With a little bit of  
tweaking, perhaps this core conversion from python data structures to  
correctly encoded bytes for transmission over the wire could be  
broken out from Nevow so other projects could benefit from it.

Quoting is so difficult to get right that if many people reimplement  
quoting, some of the implementations are sure to be wrong simply  
because there are so many corner cases. It seems like this might be  
one area where it would be both beneficial and possible to share code  
between Python web frameworks.

dp

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/web-sig/attachments/20050425/a45501bb/attachment.html


More information about the Web-SIG mailing list