Fix unicode in attr values

This commit is contained in:
William Toohey 2017-07-21 01:00:13 +10:00
parent d4514ea4be
commit a6c27eef65
5 changed files with 6 additions and 6 deletions

View File

@ -67,13 +67,13 @@ class KBinXML():
def data_grab_auto(self):
size = self.dataBuf.get_s32()
ret = self.dataBuf.get('b', size)
ret = self.dataBuf.get('B', size)
self.dataBuf.realign_reads()
return ret
def data_append_auto(self, data):
self.dataBuf.append_s32(len(data))
self.dataBuf.append(data, 'b', len(data))
self.dataBuf.append(data, 'B', len(data))
self.dataBuf.realign_writes()
def data_grab_string(self):

View File

@ -12,9 +12,9 @@ with open('testcases_out.kbin', 'rb') as f:
k = KBinXML(xml_in)
kbin = k.to_binary()
if kbin != expected_bin:
with open('failed_test.bin', 'wb') as f:
with open('failed_test.kbin', 'wb') as f:
f.write(kbin)
raise AssertionError('Binary output does not match, check failed_test.bin')
raise AssertionError('Binary output does not match, check failed_test.kbin')
else:
print('XML -> Binary correct!')

View File

@ -6,7 +6,7 @@
<!-- Attributes plus text -->
<entry attr="test" attr2="best" __type="str">Hello, world!</entry>
<!-- Testing encoding, plus __type-less should become string -->
<superstar>シ イス マイ ワイフ</superstar>
<superstar babe="ミツル">シ イス マイ ワイフ</superstar>
<!-- Testing 6bit conversion -->
<xXx_T4GG3R_xXx __type="3u8">8 9 10</xXx_T4GG3R_xXx>
<!-- Shouldn't have alignment issues from the 3u8 -->

Binary file not shown.

View File

@ -2,7 +2,7 @@
<test>
<entry __type="ip4" __count="2">127.0.0.1 192.168.0.1</entry>
<entry __type="str" attr="test" attr2="best">Hello, world!</entry>
<superstar __type="str">シ イス マイ ワイフ</superstar>
<superstar __type="str" babe="ミツル">シ イス マイ ワイフ</superstar>
<xXx_T4GG3R_xXx __type="3u8">8 9 10</xXx_T4GG3R_xXx>
<aligned __type="u8">12</aligned>
<entry __type="bin" __size="4">deadbeef</entry>