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

Any unicode support? #5

Open
jocelyn opened this issue Oct 28, 2019 · 5 comments
Open

Any unicode support? #5

jocelyn opened this issue Oct 28, 2019 · 5 comments

Comments

@jocelyn
Copy link

jocelyn commented Oct 28, 2019

It seems unicode source code is well saved.
But execution of unicode printing does not seems to work fine.
Is there any example of such code?

For instance, output the unicode string "こんにちは!" ?

@adilek
Copy link

adilek commented Sep 28, 2021

Is it for Python? If yes, I can help you with that.

@jocelyn
Copy link
Author

jocelyn commented Sep 29, 2021

my use case was for Eiffel, but I think the same issue exist for Python on codeboard.

@adilek
Copy link

adilek commented Sep 29, 2021

For Python I used an additional runner where I overrode environment variables and gained unicode support.

@jocelyn
Copy link
Author

jocelyn commented Oct 1, 2021

Can you describe a bit more your solution?

@adilek
Copy link

adilek commented Dec 20, 2021

Sorry for my late reply.
In codeboard.json I changed the default runner:

{
	"_comment": "Configuration for this Python3-UnitTest project.",
	"MainFileForRunning": "./Root/runner/runner.py",
	"DirectoryForSourceFiles": "./Root",
	"DirectoryForTestFiles": "./Root/test",
	"DirectoryForTestSubmissionFiles": "./Root/submit"
}

And runner.py works as:

import io
import os
import re
import subprocess
import sys


my_env = os.environ.copy()
my_env["PYTHONIOENCODING"] = "UTF-8"

sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')
sys.stdin = io.TextIOWrapper(sys.stdin.detach(), encoding = 'utf-8')

proc = subprocess.Popen(['python3', './Root/main.py',  ''], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=my_env)
output = proc.communicate()[0].decode('UTF-8')

print(output)

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

No branches or pull requests

2 participants