Skip to content
Myr

utils.unicode_from_html

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent a94541d · Browse files · 1 file+19 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+19 added−0 removed

  • other:+19 added−0 removed

1 file+19 added−0 removed

modified:requests/utils.py+19 added
108 unmodified lines
109 if 'charset' in params:110 return params['charset'].strip("'\"")111112113def unicode_from_html(content):114 """Attempts to decode an HTML string into unicode.115 If unsuccessful, the original content is returned.116 """117118 encodings = get_encodings_from_content(content)119120 for encoding in encodings:121122 try:123 return unicode(content, encoding)124 except (UnicodeError, TypeError):125 pass126127 return content128129130131132def get_unicode_from_response(r):133 """Returns the requested content back in unicode.134135 :param r: Reponse object to get unicode content from.
36 unmodified lines