Skip to content

Commit

Permalink
fix utf-16-le cut off bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
walker8088 committed Sep 8, 2024
1 parent 40149ea commit dbea16b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cchess/read_cbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def _decode_pos(p):
return (p%9, 9-p//9)

def cut_bytes_to_str(buff):
#print(buff.hex())
zero_index = buff.find(b'\x00\x00\x00')
#print(zero_index)
return buff[:zero_index].decode(CODING_PAGE)
buff_len = len(buff)
for index in range(0, buff_len, 2):
if buff[index : index+2] == b'\x00\x00':
return buff[:index].decode(CODING_PAGE)

#-----------------------------------------------------#
class CbrBuffDecoder(object):
Expand Down

0 comments on commit dbea16b

Please sign in to comment.