1 #!/usr/bin/env python 2 3 "A test of Unicode writing." 4 5 import WebStack.Generic 6 7 class UnicodeResource: 8 9 "A Unicode test resource." 10 11 def respond(self, trans): 12 trans.set_content_type(WebStack.Generic.ContentType("text/html", "utf-8")) 13 14 # Define a Unicode sequence. 15 16 l = [] 17 for i in range(0, 4096, 64): 18 l.append("<tr>") 19 l.append("<th>%s</th>" % i) 20 for j in range(i, i+64): 21 l.append("<td>%s</td>" % unichr(j)) 22 l.append("<tr>\n") 23 s = "".join(l) 24 25 # Write the Unicode to the response. 26 27 out = trans.get_response_stream() 28 out.write(""" 29 <html> 30 <head> 31 <title>Unicode Example</title> 32 </head> 33 <body> 34 <table> 35 %s 36 </table> 37 </body> 38 </html> 39 """ % s) 40 41 # vim: tabstop=4 expandtab shiftwidth=4