UnicodeEncodeError: ‘ascii’ codec can’t encode character ‘\xe9’ – -when using urlib.request python3

Use a percent-encoded URL: link = ‘http://finance.yahoo.com/news/caf%C3%A9s-growing-faster-than-fast-food-peers-144512056.html’ I found the above percent-encoded URL by pointing the browser at http://finance.yahoo.com/news/cafés-growing-faster-than-fast-food-peers-144512056.html going to the page, then copying-and-pasting the encoded url supplied by the browser back into the text editor. However, you can generate a percent-encoded URL programmatically using: from urllib import parse link = ‘http://finance.yahoo.com/news/cafés-growing-faster-than-fast-food-peers-144512056.html’ scheme, netloc, … Read more

Decode UTF-8 with Javascript

To answer the original question: here is how you decode utf-8 in javascript: http://ecmanaut.blogspot.ca/2006/07/encoding-decoding-utf8-in-javascript.html Specifically, function encode_utf8(s) { return unescape(encodeURIComponent(s)); } function decode_utf8(s) { return decodeURIComponent(escape(s)); } We have been using this in our production code for 6 years, and it has worked flawlessly. Note, however, that escape() and unescape() are deprecated. See this.