Skip to content

Commit

Permalink
Fix passing unicode variables to evaljs
Browse files Browse the repository at this point in the history
  • Loading branch information
amol- committed May 29, 2024
1 parent b2e3d95 commit e212376
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dukpy/evaljs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def evaljs(self, code, **kwargs):
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):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_evaljs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def test_unicode_jssrc(self):
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:
Expand Down

0 comments on commit e212376

Please sign in to comment.