notebook_xterm
notebook_xterm copied to clipboard
Python3 and non-latin letters support
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.