UnicodeDecode error while printing line (#539258)
Alexander Belchenko
bialix at ukr.net
Tue Mar 16 17:46:15 GMT 2010
Parth Malwankar пишет:
> On Tue, Mar 16, 2010 at 9:31 PM, Alexander Belchenko <bialix at ukr.net> wrote:
>> Alexander Belchenko пишет:
>>> Parth Malwankar пишет:
>>>> On Tue, Mar 16, 2010 at 1:57 PM, Alexander Belchenko <bialix at ukr.net>
>>>> wrote:
>>>>> Alexander Belchenko пишет:
>
>
>>> I think this is wrong way. Especially because on Windows if you print text
>>> to the terminal you should use terminal_encoding, not user_encoding.
>>>
>>>
>>>
>
> Thanks Alexander, INADA. So this is what I have now. It seems to work
> fine with the sample data (emacs repo). Everything is using terminal
> encoding now and path is added separately after formatting.
>
> _terminal_encoding = osutils.get_terminal_encoding()
> .....
> path = path.encode(_terminal_encoding, 'replace')
> fmt = ":%s".encode(_terminal_encoding)
> .....
> for line in file_text.split("\n"):
> if patternc.search(line):
> line = line.decode(_terminal_encoding, 'replace')
> outf.write(path + (pfmt % (line,)) + eol_marker)
In this case you don't need pfmt at all, IMO.
Also you need ensure you're using encoding_type = 'exact' now.
More information about the bazaar
mailing list