UnicodeDecodeError when redirecting to file
Posted
by
zedoo
on Stack Overflow
See other posts from Stack Overflow
or by zedoo
Published on 2010-12-28T11:24:45Z
Indexed on
2010/12/28
12:53 UTC
Read the original article
Hit count: 213
Hi,
I run this snippet twice, in the ubuntu terminal, (encoding set to utf-8) once with ./test.py
and then with ./test.py >out.txt
:
uni = u"\u001A\u0BC3\u1451\U0001D10C"
print uni
Without redirection it prints garbage. With redirection I get a UnicodeDecodeError. Can someone explain why I get the error only in the second case, or even better give a detailed explanation of what's going on behind the curtain in both cases?
© Stack Overflow or respective owner