Index: controllers.py
===================================================================
--- controllers.py	(revision 1813)
+++ controllers.py	(working copy)
@@ -18,7 +18,7 @@
 
 log = logging.getLogger("turbogears.controllers")
 
-unicodechars = re.compile(r"([^\x00-\x7F])")
+http_charset = r =  re.compile("charset\\=([^ ;]+)");
 
 if turbogears.config.get("session_filter.on",None) == True:
     if turbogears.config.get("session_filter.storage_type",None) == "PostgreSQL":
@@ -81,12 +81,17 @@
     if not contentType.startswith("text/"):
         return output
     ua = view.UserAgent(ua)
-    enc = turbogears.config.get("kid.encoding", "utf-8")
-    if ua.browser == "safari":
-        if isinstance(output, str):
-            output = output.decode(enc)
-        output = unicodechars.sub(
-            lambda m: "&#x%x;" % ord(m.group(1)), output).encode("ascii")
+
+    m = http_charset.search(contentType);
+    if m: # Get encoding from HTTP header:
+        enc = m.group(1); 
+    else: # Encoding was not specified in HTTP headers. Add it:
+        enc = turbogears.config.get("kid.encoding", "utf-8")
+        if contentType.find(";") < 0:
+            contentType = contentType + ";"
+        contentType = contentType + " charset=" + enc
+        cherrypy.response.headers["Content-Type"] = contentType
+
     if isinstance(output, unicode):
         output = output.encode(enc)
     return output
