Skip to content
Snippets Groups Projects
Commit da8b863f authored by Jacob Theisen's avatar Jacob Theisen
Browse files

sjo

parent 12b7290f
No related branches found
No related tags found
No related merge requests found
...@@ -5,8 +5,7 @@ with open('./fil.txt') as file: ...@@ -5,8 +5,7 @@ with open('./fil.txt') as file:
#def checkstring(string):
# check if string contains ascii
...@@ -67,9 +66,9 @@ with open('./compresed', 'w') as file: ...@@ -67,9 +66,9 @@ with open('./compresed', 'w') as file:
print(a) print(a)
i = 0 i = 0
a = a.replace('å', 'a') '''a = a.replace('å', 'a')
a = a.replace('ø', 'o') a = a.replace('ø', 'o')
a = a.replace('æ', 'e') a = a.replace('æ', 'e')'''
''' '''
while i < len(a): while i < len(a):
......
...@@ -5,13 +5,13 @@ with open('./compresed', 'rb') as file: ...@@ -5,13 +5,13 @@ with open('./compresed', 'rb') as file:
def dcomp(): def dcomp():
dcomp_arr = bytearray('', 'utf-8') dcomp_arr = []
i = 0 i = 0
dcomp_string = '' dcomp_string = ''
togle_not_bytes = False togle_not_bytes = False
while i < (len(tekst)): while i < (len(tekst)):
if togle_not_bytes: if togle_not_bytes:
dcomp_arr.extend(tekst[i:i+num]) dcomp_arr.extend(tekst[i:i+num].decode('utf-8'))
togle_not_bytes = False togle_not_bytes = False
i += num i += num
else: else:
...@@ -27,7 +27,7 @@ def dcomp(): ...@@ -27,7 +27,7 @@ def dcomp():
togle_not_bytes = True togle_not_bytes = True
num = value num = value
i+=2 i+=2
dcomp_string = ''.join(map(chr, dcomp_arr)) dcomp_string = ''.join(dcomp_arr)
return dcomp_string return dcomp_string
......
File added
...@@ -28,4 +28,55 @@ print(b) ...@@ -28,4 +28,55 @@ print(b)
c = -((b ^ 0xff)+1) c = -((b ^ 0xff)+1)
print(c)''' print(c)'''
print(b'') import string
\ No newline at end of file
'''def checkstring(sjo):
ascii = string.printable
num = 0
for i in sjo:
if i not in ascii:
num +=1
return num
b = checkstring('åøæ')
print(b)
'''
with open('./test','wb') as file:
int2 = int('78')
file.write(int2.to_bytes(2,'little'))
with open('./test','a') as file:
file.write('abÅ')
with open('./test','rb') as file:
tekst = file.read()
arr = bytearray('', 'utf-8')
array = []
str = ''
for i in range(len(tekst)):
print(i)
if i == 1:
continue
if i == 0:
value = tekst[i:i+2]
value = int.from_bytes(value, "little")
print(value)
#bytearray.extend(value)
continue
array.extend(tekst[i:].decode('utf-8'))
print(array)
print(''.join(map(chr, arr)))
exit()
'''string_to_test = 'abå'
def test():
res = b"0x00ab"
print(res)
test()'''
#å=Ã¥ Å=
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment