UnicodeDecode error while printing line (#539258)
Parth Malwankar
parth.malwankar at gmail.com
Tue Mar 16 17:37:44 GMT 2010
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)
--
Regards,
Parth
More information about the bazaar
mailing list