Using more than 7 bit ASCII on windows.
Mark Hammond
MarkH at ActiveState.com
Sun Oct 29 18:38:16 EST 2000
Syver Enstad wrote:
> "Mark Hammond" <MarkH at ActiveState.com> wrote in message
> I read that extended characters should work in the interactive window on the
> active state page. But I can't seem to get it to work. Here are some
> examples from my interactive window (using python 2.0 with win32all 135 and
> the update you mentioned).
I think I have fixed this. Pythonwin was printing characters OK, but
wasnt _reading_ them back OK. There may be other places similar
problems will lurk, so please experiment!
Assuming you have installed 135 or ActivePython, and have installed the
update I mentioned, then you can also try the following change.
pywin\framework\interact.py, line 304. We need to add 2 lines. The
entire function in question then becomes:
def DoGetLine(self, line=-1):
if line==-1: line = self.LineFromChar()
line = self.GetLine(line)
if pywin.is_platform_unicode:
line = unicode(line, "utf-8").encode("mbcs")
while line and line[-1] in ['\r', '\n']:
line = line[:-1]
return line
(Note that indents are using tabs in the source file - it is an old one
;-). The 2 lines added are:
<tab><tab>if pywin.is_platform_unicode:
<tab><tab><tab>line = unicode(line, "utf-8").encode("mbcs")
Please try applying this, and let me know if it works. If I use the
Windows "Character Map" application to paste an extended character, this
is the behaviour I now see:
>>> s="?"
>>> s
'\337'
>>> print s
ß
>>>
(Assuming the characters make it through this new-fangled newsreader ;-)
Eeek - now the newsreader is asking me to pick the encoding due to
those characters. *sigh* My choices are all character sets with funny
numbers and names that give me no clue. *double sigh*.
Which is the same as what I get for Python.exe...
Mark.
More information about the Python-list
mailing list