[docs] printing unicode strings
Chuck Simmons
csimmons at google.com
Fri Aug 9 21:36:17 CEST 2013
Context: I'm getting
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in
position 7: ordinal not in range(128)
from the code
print '%s%s%s' % (prefix, value, suffix),
[Here, 'value' contains unicode characters, while prefix and suffix contain
7-bit characters.]
So I went to
http://docs.python.org/2/howto/unicode.html#reading-and-writing-unicode-data
to determine what I should do to fix my bug. I saw the section "Reading
and Writing Unicode
Data<http://docs.python.org/2/howto/unicode.html#reading-and-writing-unicode-data>",
which seemed relevant. That section doesn't seem to discuss printing to
stdout.
No doubt I got confused and didn't read carefully enough, but it might be
the case that if the Reading and Writing section had an example of printing
a unicode string to stdout that it would have helped me find a solution
faster.
g'luck, Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20130809/11e2eb75/attachment-0001.html>
More information about the docs
mailing list