1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/Common/Unicode/__init__.py Mon Aug 30 18:24:17 2004 +0000
1.3 @@ -0,0 +1,41 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"A test of Unicode writing."
1.7 +
1.8 +import WebStack.Generic
1.9 +
1.10 +class UnicodeResource:
1.11 +
1.12 + "A Unicode test resource."
1.13 +
1.14 + def respond(self, trans):
1.15 + trans.set_content_type(WebStack.Generic.ContentType("text/html"))
1.16 +
1.17 + # Define a Unicode sequence.
1.18 +
1.19 + l = []
1.20 + for i in range(0, 4096, 64):
1.21 + l.append("<tr>")
1.22 + l.append("<th>%s</th>" % i)
1.23 + for j in range(i, i+64):
1.24 + l.append("<td>%s</td>" % unichr(j))
1.25 + l.append("<tr>\n")
1.26 + s = "".join(l)
1.27 +
1.28 + # Write the Unicode to the response.
1.29 +
1.30 + out = trans.get_response_stream()
1.31 + out.write("""
1.32 +<html>
1.33 + <head>
1.34 + <title>Unicode Example</title>
1.35 + </head>
1.36 + <body>
1.37 + <table>
1.38 + %s
1.39 + </table>
1.40 + </body>
1.41 +</html>
1.42 +""" % s)
1.43 +
1.44 +# vim: tabstop=4 expandtab shiftwidth=4