diff --git a/asn1tools/codecs/jer.py b/asn1tools/codecs/jer.py
index 9c51da8d..2d347c2c 100644
--- a/asn1tools/codecs/jer.py
+++ b/asn1tools/codecs/jer.py
@@ -512,9 +512,9 @@ def encode(self, data, indent=None):
raise e
if indent is None:
- string = json.dumps(dictionary, separators=(',', ':'))
+ string = json.dumps(dictionary, ensure_ascii=False, separators=(',', ':'))
else:
- string = json.dumps(dictionary, indent=indent)
+ string = json.dumps(dictionary, ensure_ascii=False, indent=indent)
return string.encode('utf-8')
diff --git a/asn1tools/codecs/xer.py b/asn1tools/codecs/xer.py
index a12e3e26..a15809d0 100644
--- a/asn1tools/codecs/xer.py
+++ b/asn1tools/codecs/xer.py
@@ -662,7 +662,7 @@ def encode(self, data, indent=None):
if indent is not None:
indent_xml(element, indent * " ")
- return ElementTree.tostring(element)
+ return ElementTree.tostring(element, encoding='utf-8')
def decode(self, data):
element = ElementTree.fromstring(data.decode('utf-8'))
diff --git a/tests/test_xer.py b/tests/test_xer.py
index 299d15e2..ec38f5b8 100644
--- a/tests/test_xer.py
+++ b/tests/test_xer.py
@@ -328,8 +328,8 @@ def test_utf8_string(self):
datas = [
('A', u'', b''),
('A', u'bar', b'bar'),
- ('A', u'a\u1010c', b'aတc'),
- ('A', u'f → ∝', b'f → ∝')
+ ('A', u'a\u1010c', b'a\xe1\x80\x90c'),
+ ('A', u'f → ∝', b'f \xe2\x86\x92 \xe2\x88\x9d'),
]
for type_name, decoded, encoded in datas: