Convert characters from the locale's encoding on output.
Reject characters outside the locale's encoding on input.
diff --git a/Tools/idle/OutputWindow.py b/Tools/idle/OutputWindow.py
index f429f2e..0e7fba2 100644
--- a/Tools/idle/OutputWindow.py
+++ b/Tools/idle/OutputWindow.py
@@ -2,6 +2,7 @@
 from EditorWindow import EditorWindow
 import re
 import tkMessageBox
+import IOBinding
 
 class OutputWindow(EditorWindow):
 
@@ -34,6 +35,14 @@
     # Act as output file
 
     def write(self, s, tags=(), mark="insert"):
+        # Tk assumes that byte strings are Latin-1;
+        # we assume that they are in the locale's encoding
+        if isinstance(s, str):
+            try:
+                s = unicode(s, IOBinding.encoding)
+            except UnicodeError:
+                # some other encoding; let Tcl deal with it
+                pass
         self.text.insert(mark, s, tags)
         self.text.see(mark)
         self.text.update()