Skip to content

Commit

Permalink
Merge pull request #1 from faithandbrave/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Theelx authored Aug 18, 2022
2 parents 431c552 + e684ff9 commit 9475251
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions base122.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@ def encode(rawData, warnings=True):
def get7(rawDataLen):
nonlocal curIndex, curBit, rawData
if curIndex >= rawDataLen:
return False
return False, 0
firstPart = (
(((0b11111110 % 0x100000000) >> curBit) & rawData[curIndex]) << curBit
) >> 1
curBit += 7
if curBit < 8 or curIndex >= rawDataLen:
return firstPart
if curBit < 8:
return True, firstPart
curBit -= 8
curIndex += 1
if curIndex >= rawDataLen:
return firstPart
return True, firstPart
secondPart = (
(((0xFF00 % 0x100000000) >> curBit) & rawData[curIndex]) & 0xFF
) >> (8 - curBit)
return firstPart | secondPart
return True, firstPart | secondPart

# for loops don't work because they cut off a variable amount of end letters for some reason, but they'd speed it up immensely
while True:
bits = get7(len(rawData))
if not bits:
retBits, bits = get7(len(rawData))
if not retBits:
break
if bits in kIllegalsSet:
illegalIndex = kIllegals.index(bits)
else:
outData.append(bits)
continue
nextBits = get7(len(rawData))
retNext, nextBits = get7(len(rawData))
b1 = 0b11000010
b2 = 0b10000000
if not nextBits:
if not retNext:
b1 |= (0b111 & kShortened) << 2
nextBits = bits
else:
Expand All @@ -71,7 +71,7 @@ def decode(strData, warnings=True):
)
# null, newline, carriage return, double quote, ampersand, backslash
decoded = []
decodedIndex = curByte = bitOfByte = 0
curByte = bitOfByte = 0

# this could test for every letter in the for loop, but I took it out for performance
if not isinstance(strData[0], int):
Expand Down

0 comments on commit 9475251

Please sign in to comment.