Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError when piping Unicode output #42

Closed
macro opened this issue Apr 12, 2012 · 0 comments
Closed

UnicodeEncodeError when piping Unicode output #42

macro opened this issue Apr 12, 2012 · 0 comments
Labels
bug Something isn't working

Comments

@macro
Copy link

macro commented Apr 12, 2012

Terminal supports UTF-8:

$ echo $LANG
en_US.UTF-8

Printing to stdout is OK:

$ python -mhttpie GET news.ycombinator.org  --pretty 
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: private
Connection: close
Cache-Control: max-age=0
<snip/>

Piping Unicode output to a pager (or anything else reading from stdin) results in UnicodeEncodeError

$ python -mhttpie GET news.ycombinator.org  --pretty | less
Traceback (most recent call last):
  File "/opt/local/lib/python3.2/runpy.py", line 160, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/opt/local/lib/python3.2/runpy.py", line 73, in _run_code
    exec(code, run_globals)
  File "/opt/src/httpie/httpie/__main__.py", line 193, in <module>
    main()
  File "/opt/src/httpie/httpie/__main__.py", line 187, in main
    with_body=cli.OUT_RESPONSE_BODY in args.output_options
UnicodeEncodeError: 'ascii' codec can't encode character '\u2013' in position 13305: ordinal not in range(128)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants