Browse Source

utf-8 support for TT code redemption

Darren Ranalli 15 years ago
parent
commit
b539af35b7
2 changed files with 9 additions and 3 deletions
  1. 2 0
      direct/src/http/LandingPageHTML.py
  2. 7 3
      direct/src/showbase/PythonUtil.py

+ 2 - 0
direct/src/http/LandingPageHTML.py

@@ -283,8 +283,10 @@ stylesheet = '''
 \r\n'''
 
 header = '''
+<?xml version="1.0" encoding="UTF-8"?>
 <html>
 %(headTag)s
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <title>%(titlestring)s</title>
 <link rel="stylesheet" type="text/css" href="/default.css">
 </head>

+ 7 - 3
direct/src/showbase/PythonUtil.py

@@ -55,6 +55,7 @@ import marshal
 import ElementTree as ET
 from HTMLParser import HTMLParser
 import BpDb
+import unicodedata
 
 __report_indent = 3
 
@@ -336,12 +337,12 @@ def traceFunctionCall(frame):
         r+=name
         r+='='
         if name in dict:
-            v=str(dict[name])
+            v=safeRepr(dict[name])
             if len(v)>2000:
                 # r+="<too big for debug>"
-                r += (str(dict[name])[:2000] + "...")
+                r += (v[:2000] + "...")
             else:
-                r+=str(dict[name])
+                r+=v
         else: r+="*** undefined ***"
     return r+')'
 
@@ -4322,6 +4323,8 @@ def bpdbGetEnabled():
 bpdb.setEnabledCallback(bpdbGetEnabled)
 bpdb.setConfigCallback(lambda cfg: ConfigVariableBool('want-bp-%s' % (cfg.lower(),), 0).getValue())
 
+def u2ascii(str):
+    return unicodedata.normalize('NFKD', str).encode('ascii','ignore')
 
 import __builtin__
 __builtin__.Functor = Functor
@@ -4384,3 +4387,4 @@ __builtin__.safeTypeName = safeTypeName
 __builtin__.histogramDict = histogramDict
 __builtin__.repeatableRepr = repeatableRepr
 __builtin__.bpdb = bpdb
+__builtin__.u2ascii = u2ascii