question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redirect to file fails!

See original GitHub issue
from __future__ import unicode_literals
import win_unicode_console
win_unicode_console.enable()
print u"ÄäБб"

Works if it’s called from console, but as far as it’s redirected to a file:

print u"ÄäБб"
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:44 (21 by maintainers)

github_iconTop GitHub Comments

2reactions
Drekincommented, Aug 23, 2016

When I try py -3 -c "print('α')" > out.txt, it saves as utf-8 when PYTHONIOENCODING=utf-8 is set. If you are talking about output to console, then of course it doesn’t work, that’s why win_unicode_console exists in the first place.

1reaction
Drekincommented, Aug 23, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

Linux Redirect Error Output To File - nixCraft
Linux Redirect Error Output To File ; Syntax To redirect all output to file. The syntax is as follows to redirect output (stdout)...
Read more >
How to redirect stderr to a file [duplicate] - Ask Ubuntu
Redirect stdout to one file and stderr to another file: command > out 2>error · Redirect stdout to a file ( >out ),...
Read more >
How to redirect and append both standard output and ...
>>file.txt : Open file.txt in append mode and redirect stdout there. ... if you want to pipe standard output and standard error to...
Read more >
Redirecting error from Command Prompt - Visual C++
This article describes redirecting error messages from Command Prompt. ... The command dir file.xxx (where file.xxx does not exist) will ...
Read more >
Modify 2>&1 so that output goes to a specific file and any ...
Don't hang, use ampersand & to move on to the next command · Output the data generated by the command to file data.json...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found