fix FixedStrFormat encode
This commit is contained in:
parent
8921b41374
commit
e11121a4a4
1 changed files with 2 additions and 2 deletions
|
@ -497,8 +497,8 @@ class FixedStrFormat(SimpleFormat):
|
||||||
self.num = num
|
self.num = num
|
||||||
super().__init__('%ds' % self.num)
|
super().__init__('%ds' % self.num)
|
||||||
|
|
||||||
def encode(self, value: str):
|
def encode(self, value: str) -> bytes:
|
||||||
return value.encode()[:self.num].ljust(self.num, bytes((0,))),
|
return value.encode()[:self.num].ljust(self.num, bytes((0,)))
|
||||||
|
|
||||||
def decode(self, data: bytes) -> tuple[str, bytes]:
|
def decode(self, data: bytes) -> tuple[str, bytes]:
|
||||||
return data[:self.num].rstrip(bytes((0,))).decode(), data[self.num:]
|
return data[:self.num].rstrip(bytes((0,))).decode(), data[self.num:]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue