fix: Chinese encoding under LAN Control (#1114)

This commit is contained in:
a3d21 2025-05-22 11:28:11 +08:00 committed by GitHub
parent 00f24bd3e1
commit a83ad60b38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -226,7 +226,7 @@ class _MIoTLanDevice:
def gen_packet( def gen_packet(
self, out_buffer: bytearray, clear_data: dict, did: str, offset: int self, out_buffer: bytearray, clear_data: dict, did: str, offset: int
) -> int: ) -> int:
clear_bytes = json.dumps(clear_data).encode('utf-8') clear_bytes = json.dumps(clear_data, ensure_ascii=False).encode('utf-8')
padder = padding.PKCS7(algorithms.AES128.block_size).padder() padder = padding.PKCS7(algorithms.AES128.block_size).padder()
padded_data = padder.update(clear_bytes) + padder.finalize() padded_data = padder.update(clear_bytes) + padder.finalize()
if len(padded_data) + self.OT_HEADER_LEN > len(out_buffer): if len(padded_data) + self.OT_HEADER_LEN > len(out_buffer):