UnicodeDecode error while printing line (#539258)

Parth Malwankar parth.malwankar at gmail.com
Tue Mar 16 17:52:18 GMT 2010


On Tue, Mar 16, 2010 at 11:16 PM, Alexander Belchenko <bialix at ukr.net> wrote:
> 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.
>

Yes. I have removed pfmt and set the encoding_type.
I think I understand unicode better now :-)

Thanks.
Parth



More information about the bazaar mailing list