Исправление BattleCoder, (текущая версия) :
def unescape(data):
i = iter(data)
while True:
try:
x = next(i)
yield next(i) ^ 0x7D if x == 0x7D else x
except StopIteration:
break
p.s. код не проверял, мог допустить ошибку, но принцип такой.
p.p.s. наверное можно и проще без десятиэтажных конструкций
Исправление BattleCoder, :
def unescape(data):
i = iter(data)
while True:
try:
x = next(i)
if x == 0x7D:
yield next(i) ^ 0x7D
else:
yield x
except StopIteration:
break
p.s. код не проверял, мог допустить ошибку, но принцип такой.
p.p.s. наверное можно и проще без десятиэтажных конструкций
Исправление BattleCoder, :
def unescape(data):
i = iter(data)
while True:
try:
x = next(i)
if x == 0x7D:
x = next(i)
yield x ^ 0x7D
else:
yield x
except StopIteration:
break
p.s. код не проверял, мог допустить ошибку, но принцип такой.
p.p.s. наверное можно и проще без десятиэтажных конструкций
Исправление BattleCoder, :
def unescape(data):
i = iter(data)
while True:
try:
x = next(i)
if x == 0x7D:
x = next(i)
yield x ^ 0x7D
else:
yield x
except StopIteration:
break
p.s. код не проверял, мог допустить ошибку, но принцип такой.
Исправление BattleCoder, :
def unescape(data):
i = iter(data)
while True:
try:
x = next(i)
if x == 0x7D:
x = next(data)
yield x ^ 0x7D
else:
yield x
except StopIteration:
break
p.s. код не проверял, мог допустить ошибку, но принцип такой.
Исправление BattleCoder, :
def unescape(data):
i = iter(data)
while True:
try:
x = next(i)
if x == 0x7D:
x = next(data)
yield x ^ 0x7D
else:
yield x
except StopIteration:
break
Исходная версия BattleCoder, :
def unescape(data):
while True:
x = next(data)
if x == 0x7D:
x = next(data)
yield x ^ 0x7D
else:
yield x