Fixed Unicode string encoding issues for python 2/3.#30
Fixed Unicode string encoding issues for python 2/3.#30goerlitz wants to merge 1 commit intosmilli:masterfrom
Conversation
| data = text.encode() | ||
| # ensure proper encoding of python 3 strings | ||
| if sys.version_info.major >= 3: | ||
| text = text.encode('utf-8') |
There was a problem hiding this comment.
why not text.encode('utf-8') for python 2?
Short Explanation:Python 3 uses unicode by default while python 2 differentiates between ASCII and unicode. Therefore, if Longer Explanation:In python 3, Since function Consequently, |
As mentioned in #29 Unicode strings are not properly handled when using Python 2 and lead to exceptions.
This fix makes sure that Unicode string encoding works for Python 2 and Python 3 as well.