Skip to content

Commit 9d9b2aa

Browse files
committed
_writeString: Convert strings to bytes as UTF-8
Note that Java uses a modified UTF-8 format in serialized file => http://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html#modified-utf-8
1 parent 60ed5f6 commit 9d9b2aa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

javaobj.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,10 @@ def _writeString(self, string):
11521152
11531153
:param string: String to serialize
11541154
"""
1155+
# TODO: Convert to "modified UTF-8"
1156+
# http://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html#modified-utf-8
1157+
string = to_bytes(string, "utf-8")
1158+
11551159
self._writeStruct(">H", 2, (len(string),))
11561160
self.object_stream.write(string)
11571161

0 commit comments

Comments
 (0)