4949 to_str ,
5050 to_unicode ,
5151 UNICODE_TYPE ,
52+ unicode_char ,
5253)
5354
5455try :
@@ -1008,7 +1009,7 @@ def do_array(self, parent=None, ident=0):
10081009 else :
10091010 for _ in range (size ):
10101011 res = self ._read_value (type_char , ident )
1011- log_debug ("Native value: {0}" .format (res ), ident )
1012+ log_debug ("Native value: {0}" .format (repr ( res ) ), ident )
10121013 array .append (res )
10131014
10141015 return array
@@ -1113,7 +1114,7 @@ def _read_value(self, field_type, ident, name=""):
11131114 # TYPE_CHAR is defined by the serialization specification
11141115 # but not used in the implementation, so this is
11151116 # a hypothetical code
1116- res = bytes (self ._readStruct (">bb" )). decode ( "utf-16-be" )
1117+ res = unicode_char (self ._readStruct (">H" )[ 0 ] )
11171118 elif field_type == self .TYPE_SHORT :
11181119 (res ,) = self ._readStruct (">h" )
11191120 elif field_type == self .TYPE_INTEGER :
@@ -1129,7 +1130,7 @@ def _read_value(self, field_type, ident, name=""):
11291130 else :
11301131 raise RuntimeError ("Unknown typecode: {0}" .format (field_type ))
11311132
1132- log_debug ("* {0} {1}: {2}" .format (field_type , name , res ), ident )
1133+ log_debug ("* {0} {1}: {2}" .format (field_type , name , repr ( res ) ), ident )
11331134 return res
11341135
11351136 def _convert_char_to_type (self , type_char ):
@@ -1602,6 +1603,8 @@ def _write_value(self, field_type, value):
16021603 self ._writeStruct (">B" , 1 , (1 if value else 0 ,))
16031604 elif field_type == self .TYPE_BYTE :
16041605 self ._writeStruct (">b" , 1 , (value ,))
1606+ elif field_type == self .TYPE_CHAR :
1607+ self ._writeStruct (">H" , 1 , (ord (value ),))
16051608 elif field_type == self .TYPE_SHORT :
16061609 self ._writeStruct (">h" , 1 , (value ,))
16071610 elif field_type == self .TYPE_INTEGER :
0 commit comments