Encoding error while executong code from CodeMirror block.

I’m implementing an online Python compiler for which I am using codemirror. When I try to execute the code from codemirror block, it is giving an error.

Here you can see the codemirror block and “Run” button.

On clicking “Run” button, I’m sharing code with our designed online IDE through localstorage.

Executing code in an online compiler giving us an error as

File “script.py”, line 1
SyntaxError: Non-UTF-8 code starting with ‘\x87’ in file script.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Looks like this is encoding issue. Please guide me.

This is not related to CodeMirror. Inside JavaScript land, pretty much everything uses the UTF16 encoding in JavaScript strings, and so does CodeMirror. When you send such a string to the server via an HTTP request (or write it into a buffer first), you’re responsible for setting the encoding correctly.

I understand it is not codemirror issue. Can you please guide me if you know to fix this? It will be really helpful as I already spend a month debugging it and trying different things. But no luck :frowning: