[BUNDLE] Make additional chance to obtain right encoding of console when output piped

Alexander Belchenko bialix at ukr.net
Fri Jun 9 17:57:49 BST 2006


I wrote about this fact before: when output of bzr command piped to
another program, i.e. when run something like:

bzr log | less

Then sys.stdout lose their own encoding attribute value and bzr switch
to use bzrlib.user_encoding value. That behaviour on some system is
inappropriate, see bug 5041 as example.

But when only stdout piped out then stdin is not touched and behaves
normally. So bzr should try to use information from sys.stdin.encoding
to detect *right* encoding of console.

I make small improvements to the function that detect output_encoding
and give a chance to use stdin encoding when stdout piped. This patch
allow me to obtain log with russian messages in right encoding when I
run bzr simply in console or when output piped to 'less' pager.

If someone think that this patch will not works in some circumstances
then speak on. I'm willing to restrict this solution only to win32
platform. Otherwise give me +.

--
Alexander

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: using-stdin-encoding.bundle
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20060609/537135d3/attachment.diff 


More information about the bazaar mailing list