jevey / idapython

Automatically exported from code.google.com/p/idapython
Other
1 stars 0 forks source link

STDOUT / STDERR replacement fails at unicode #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I recently did something like 'print var' from my script. var contained a
unicode string. I don't recall the exact effect, but IDA's message window
did not like it at all.

I updated MyStdOut in init.py:

class MyStdOut:
    """
    Dummy file-like class that receives stout and stderr
    """
    def write(self, text):
        if isinstance(text, unicode):
            text = text.encode('ascii', "replace")
        _idaapi.msg(text.replace("%", "%%"))

This fixes it, at the cost of converting unicode to ascii, ignoring
extended characters.

Original issue reported on code.google.com by tildepa...@gmail.com on 19 Jul 2009 at 1:26

GoogleCodeExporter commented 9 years ago
Fixed. The text is now decoded through the ascii filter and all non-printable 
characters replaced with ?

See http://code.google.com/p/idapython/source/detail?r=208

Original comment by gergely.erdelyi on 21 Jul 2009 at 6:15