diff --git a/ToolsTOPX.py b/ToolsTOPX.py index 150e861..2522156 100644 --- a/ToolsTOPX.py +++ b/ToolsTOPX.py @@ -475,7 +475,63 @@ class ToolsTOPX(ToolsTales): return final_text, pos - + def text_to_bytes(self, text): + + splitLineBreak = text.split('\x0A') + nb = len(splitLineBreak) + bytesFinal = b'' + i=0 + + for line in splitLineBreak: + string_hex = re.split(self.HEX_TAG, line) + string_hex = [sh for sh in string_hex if sh] + #print(string_hex) + for s in string_hex: + if re.match(self.HEX_TAG, s): + bytesFinal += struct.pack("B", int(s[1:3], 16)) + else: + s_com = re.split(self.COMMON_TAG, s) + s_com = [sc for sc in s_com if sc] + + for c in s_com: + + if re.match(self.COMMON_TAG, c): + if ":" in c: + split = c.split(":") + + if split[0][1:] in self.itags.keys(): + bytesFinal += struct.pack("B", self.itags[split[0][1:]]) + bytesFinal += struct.pack("","") + ")" + bytesFinal += c.encode("cp932") + + if c in self.icolors: + bytesFinal += struct.pack("B", 0x5) + bytesFinal += struct.pack("=2 and i