Fix passing unicode variables to evaljs

This commit is contained in:
Alessandro Molina 2024-05-30 00:45:47 +02:00
parent b2e3d95f6b
commit e212376227
2 changed files with 5 additions and 1 deletions

View File

@ -45,7 +45,7 @@ class JSInterpreter(object):
Returns the last object on javascript stack.
"""
jsvars = json.dumps(kwargs)
jsvars = json.dumps(kwargs, ensure_ascii=False)
jscode = self._adapt_code(code)
if not isinstance(jscode, bytes):

View File

@ -29,6 +29,10 @@ class TestEvalJS(unittest.TestCase):
s = dukpy.evaljs("dukpy.c + ''", c="")
assert s == '華華'
def test_unicode_emoji(self):
s = dukpy.evaljs("dukpy.c + ''", c="🏠")
assert s == '🏠華'
def test_eval_files(self):
testfile = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'test.js')
with open(testfile) as f: