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

Python3 and non-latin letters support #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

smihael
Copy link

@smihael smihael commented Feb 3, 2022

Python 3 handles strings with two different types.

sys.stdout.write(data)

expects type(data) to be <class 'str'> and not <class 'bytes'>, so we have to tell how to decode bytes to str. See https://stackoverflow.com/a/21689447/822644

To handle non-latin letters, such as "č", some modifications had to be done in Javascript wrapper as well. btoa and atob both expect only latin letters. Usual trick is to use unescape(encodeURIComponent(letters)) in atob and decodeURIComponent(escape(bytes)) in btoa.

resolves "TypeError: write() argument must be str, not bytes"
resolves "InvalidCharacterError: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant