notebook_xterm icon indicating copy to clipboard operation
notebook_xterm copied to clipboard

Python3 and non-latin letters support

Open smihael opened this issue 3 years ago • 0 comments

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.

smihael avatar Feb 03 '22 22:02 smihael