Support » Plugin: CodeMirror Blocks » Encoding error while executong code from CodeMirror block.

  • Resolved pcskull

    (@pcskull)


    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.

    https://www.csestack.org/for-loop-else-empty-django-template/

    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 us.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Vicky Agravat

    (@vickyagravat)

    Hey @pcskull

    I have checked your site.

    You are using local storage to copy code data at: https://www.csestack.org/for-loop-else-empty-django-template/ from code block, when Execute Code button is clicked. and new page will open with copied code in the IDE at: https://www.csestack.org/ide/
    This is perfectly fine.

    Case 1

    But, I have find one problem here, The language select dropdown is not pre selected with Python, by default it is selected with C language.

    That may be a problem.
    Before changing the language selector i click Execute button, i got encoding error in response of the request.

    But, after change the language selector dropdown to Python 3 or Python 2 and click Execute button, I will get expected output.

    Case 2

    If you still get error after Python 3 or Python 2 is as selected language, There may be problem when you are convert the code string into base64 encoding.

    It may get any extra whitespace or other non printable character at the beginning of the string.

    What you should do?

    You can check decoded string result at: https://executecode.csestack.org/submissions?base64_encoded=true on your server side. you can check is there any unexpected character in the string, before compilation.
    I think this should work.

    Please Note: This forum is not for this type of question. Because, it is totally custom work.

    If you want to get any extra help from me, Skype Me: live:vicky.agravat
    Thank you.

    Thread Starter pcskull

    (@pcskull)

    Thanks for your kind reply and this awesome plugin. The issue is resolved. There was some encoding issue. And sorry for using this space to ask the question. Marking this as resolved.

    Plugin Author Vicky Agravat

    (@vickyagravat)

    Hello @pcskull

    Good to know that you have resolved the problem.

    If you like the plugin, you can leave review with good rating.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.