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

done opg1

parent cd392943
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ with open('./fil.txt') as file: ...@@ -4,7 +4,7 @@ with open('./fil.txt') as file:
tekst = file.read() tekst = file.read()
extended_string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
def run_comp(): def run_comp():
...@@ -25,8 +25,12 @@ def run_comp(): ...@@ -25,8 +25,12 @@ def run_comp():
#add the remaing string #add the remaing string
output += text[-diff:len(text)] output += text[-diff:len(text)]
for j in text[-diff:len(text)]: for j in text[-diff:len(text)]:
if j not in string.printable: if j not in string.printable and j not in extended_string:
extra_bytes_counter +=2
elif j not in string.printable:
extra_bytes_counter +=1 extra_bytes_counter +=1
#add the last counter for uncompresed chars #add the last counter for uncompresed chars
output = output[:tmp_index_to_store_counter] + f'[{(index + increment)-tmp_index_in_input+extra_bytes_counter}]' + output[tmp_index_to_store_counter:] output = output[:tmp_index_to_store_counter] + f'[{(index + increment)-tmp_index_in_input+extra_bytes_counter}]' + output[tmp_index_to_store_counter:]
return output return output
...@@ -58,9 +62,11 @@ def run_comp(): ...@@ -58,9 +62,11 @@ def run_comp():
else: else:
#if substring not procesed, add letter to output and incremnet index #if substring not procesed, add letter to output and incremnet index
output += text[index] output += text[index]
index +=1 if text[index] not in string.printable and text[index] not in extended_string:
if text[index] not in string.printable: extra_bytes_counter +=2
elif text[index] not in string.printable:
extra_bytes_counter +=1 extra_bytes_counter +=1
index +=1
...@@ -131,7 +137,9 @@ while True: ...@@ -131,7 +137,9 @@ while True:
with open('./compresed', 'a') as file: with open('./compresed', 'a') as file:
#print(a[i + len_of_int+1:i + len_of_int+1+int1]) #print(a[i + len_of_int+1:i + len_of_int+1+int1])
for j in a[i + len_of_int+1:i + len_of_int+1+int1]: for j in a[i + len_of_int+1:i + len_of_int+1+int1]:
if j not in string.printable: if j not in string.printable and j not in extended_string:
extra_bytes_counter2 += 2
elif j not in string.printable:
extra_bytes_counter2 += 1 extra_bytes_counter2 += 1
file.write(a[i + len_of_int+1:i + len_of_int+1+int1 - extra_bytes_counter2]) file.write(a[i + len_of_int+1:i + len_of_int+1+int1 - extra_bytes_counter2])
i += len_of_int + int1 + 2 - extra_bytes_counter2 i += len_of_int + int1 + 2 - extra_bytes_counter2
......
No preview for this file type
...@@ -5,7 +5,6 @@ with open('./compresed', 'rb') as file: ...@@ -5,7 +5,6 @@ with open('./compresed', 'rb') as file:
def dcomp(): def dcomp():
i = 0 i = 0
dcomp_string = '' dcomp_string = ''
......
This diff is collapsed.
U+00A1 ¡ \xc2\xa1 ¡ ¡ INVERTED EXCLAMATION MARK
U+00A2 ¢ \xc2\xa2 ¢ ¢ CENT SIGN
U+00A3 £ \xc2\xa3 £ £ POUND SIGN
U+00A4 ¤ \xc2\xa4 ¤ ¤ CURRENCY SIGN
U+00A5 ¥ \xc2\xa5 ¥ ¥ YEN SIGN
U+00A6 ¦ \xc2\xa6 ¦ ¦ BROKEN BAR
U+00A7 § \xc2\xa7 § § SECTION SIGN
U+00A8 ¨ \xc2\xa8 ¨ ¨ DIAERESIS
U+00A9 © \xc2\xa9 © © COPYRIGHT SIGN
U+00AA ª \xc2\xaa ª ª FEMININE ORDINAL INDICATOR
U+00AB « \xc2\xab « « LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
U+00AC ¬ \xc2\xac ¬ ¬ NOT SIGN
U+00AD ­ \xc2\xad ­ ­ SOFT HYPHEN
U+00AE ® \xc2\xae ® ® REGISTERED SIGN
U+00AF ¯ \xc2\xaf ¯ ¯ MACRON
U+00B0 ° \xc2\xb0 ° ° DEGREE SIGN
U+00B1 ± \xc2\xb1 ± ± PLUS-MINUS SIGN
U+00B2 ² \xc2\xb2 ² ² SUPERSCRIPT TWO
U+00B3 ³ \xc2\xb3 ³ ³ SUPERSCRIPT THREE
U+00B4 ´ \xc2\xb4 ´ ´ ACUTE ACCENT
U+00B5 µ \xc2\xb5 µ µ MICRO SIGN
U+00B6 ¶ \xc2\xb6 ¶ ¶ PILCROW SIGN
U+00B7 · \xc2\xb7 · · MIDDLE DOT
U+00B8 ¸ \xc2\xb8 ¸ ¸ CEDILLA
U+00B9 ¹ \xc2\xb9 ¹ ¹ SUPERSCRIPT ONE
U+00BA º \xc2\xba º º MASCULINE ORDINAL INDICATOR
U+00BB » \xc2\xbb » » RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
U+00BC ¼ \xc2\xbc ¼ ¼ VULGAR FRACTION ONE QUARTER
U+00BD ½ \xc2\xbd ½ ½ VULGAR FRACTION ONE HALF
U+00BE ¾ \xc2\xbe ¾ ¾ VULGAR FRACTION THREE QUARTERS
U+00BF ¿ \xc2\xbf ¿ ¿ INVERTED QUESTION MARK
U+00C0 À \xc3\x80 À À LATIN CAPITAL LETTER A WITH GRAVE
U+00C1 Á \xc3\x81 Á Á LATIN CAPITAL LETTER A WITH ACUTE
U+00C2 Â \xc3\x82 Â Â LATIN CAPITAL LETTER A WITH CIRCUMFLEX
U+00C3 Ã \xc3\x83 Ã Ã LATIN CAPITAL LETTER A WITH TILDE
U+00C4 Ä \xc3\x84 Ä Ä LATIN CAPITAL LETTER A WITH DIAERESIS
U+00C5 Å \xc3\x85 Å Å LATIN CAPITAL LETTER A WITH RING ABOVE
U+00C6 Æ \xc3\x86 Æ Æ LATIN CAPITAL LETTER AE
U+00C7 Ç \xc3\x87 Ç Ç LATIN CAPITAL LETTER C WITH CEDILLA
U+00C8 È \xc3\x88 È È LATIN CAPITAL LETTER E WITH GRAVE
U+00C9 É \xc3\x89 É É LATIN CAPITAL LETTER E WITH ACUTE
U+00CA Ê \xc3\x8a Ê Ê LATIN CAPITAL LETTER E WITH CIRCUMFLEX
U+00CB Ë \xc3\x8b Ë Ë LATIN CAPITAL LETTER E WITH DIAERESIS
U+00CC Ì \xc3\x8c Ì Ì LATIN CAPITAL LETTER I WITH GRAVE
U+00CD Í \xc3\x8d Í Í LATIN CAPITAL LETTER I WITH ACUTE
U+00CE Î \xc3\x8e Î Î LATIN CAPITAL LETTER I WITH CIRCUMFLEX
U+00CF Ï \xc3\x8f Ï Ï LATIN CAPITAL LETTER I WITH DIAERESIS
U+00D0 Ð \xc3\x90 Ð Ð LATIN CAPITAL LETTER ETH
U+00D1 Ñ \xc3\x91 Ñ Ñ LATIN CAPITAL LETTER N WITH TILDE
U+00D2 Ò \xc3\x92 Ò Ò LATIN CAPITAL LETTER O WITH GRAVE
U+00D3 Ó \xc3\x93 Ó Ó LATIN CAPITAL LETTER O WITH ACUTE
U+00D4 Ô \xc3\x94 Ô Ô LATIN CAPITAL LETTER O WITH CIRCUMFLEX
U+00D5 Õ \xc3\x95 Õ Õ LATIN CAPITAL LETTER O WITH TILDE
U+00D6 Ö \xc3\x96 Ö Ö LATIN CAPITAL LETTER O WITH DIAERESIS
U+00D7 × \xc3\x97 × × MULTIPLICATION SIGN
U+00D8 Ø \xc3\x98 Ø Ø LATIN CAPITAL LETTER O WITH STROKE
U+00D9 Ù \xc3\x99 Ù Ù LATIN CAPITAL LETTER U WITH GRAVE
U+00DA Ú \xc3\x9a Ú Ú LATIN CAPITAL LETTER U WITH ACUTE
U+00DB Û \xc3\x9b Û Û LATIN CAPITAL LETTER U WITH CIRCUMFLEX
U+00DC Ü \xc3\x9c Ü Ü LATIN CAPITAL LETTER U WITH DIAERESIS
U+00DD Ý \xc3\x9d Ý Ý LATIN CAPITAL LETTER Y WITH ACUTE
U+00DE Þ \xc3\x9e Þ Þ LATIN CAPITAL LETTER THORN
U+00DF ß \xc3\x9f ß ß LATIN SMALL LETTER SHARP S
U+00E0 à \xc3\xa0 à à LATIN SMALL LETTER A WITH GRAVE
U+00E1 á \xc3\xa1 á á LATIN SMALL LETTER A WITH ACUTE
U+00E2 â \xc3\xa2 â â LATIN SMALL LETTER A WITH CIRCUMFLEX
U+00E3 ã \xc3\xa3 ã ã LATIN SMALL LETTER A WITH TILDE
U+00E4 ä \xc3\xa4 ä ä LATIN SMALL LETTER A WITH DIAERESIS
U+00E5 å \xc3\xa5 å å LATIN SMALL LETTER A WITH RING ABOVE
U+00E6 æ \xc3\xa6 æ æ LATIN SMALL LETTER AE
U+00E7 ç \xc3\xa7 ç ç LATIN SMALL LETTER C WITH CEDILLA
U+00E8 è \xc3\xa8 è è LATIN SMALL LETTER E WITH GRAVE
U+00E9 é \xc3\xa9 é é LATIN SMALL LETTER E WITH ACUTE
U+00EA ê \xc3\xaa ê ê LATIN SMALL LETTER E WITH CIRCUMFLEX
U+00EB ë \xc3\xab ë ë LATIN SMALL LETTER E WITH DIAERESIS
U+00EC ì \xc3\xac ì ì LATIN SMALL LETTER I WITH GRAVE
U+00ED í \xc3\xad í í LATIN SMALL LETTER I WITH ACUTE
U+00EE î \xc3\xae î î LATIN SMALL LETTER I WITH CIRCUMFLEX
U+00EF ï \xc3\xaf ï ï LATIN SMALL LETTER I WITH DIAERESIS
U+00F0 ð \xc3\xb0 ð ð LATIN SMALL LETTER ETH
U+00F1 ñ \xc3\xb1 ñ ñ LATIN SMALL LETTER N WITH TILDE
U+00F2 ò \xc3\xb2 ò ò LATIN SMALL LETTER O WITH GRAVE
U+00F3 ó \xc3\xb3 ó ó LATIN SMALL LETTER O WITH ACUTE
U+00F4 ô \xc3\xb4 ô ô LATIN SMALL LETTER O WITH CIRCUMFLEX
U+00F5 õ \xc3\xb5 õ õ LATIN SMALL LETTER O WITH TILDE
U+00F6 ö \xc3\xb6 ö ö LATIN SMALL LETTER O WITH DIAERESIS
U+00F7 ÷ \xc3\xb7 ÷ ÷ DIVISION SIGN
U+00F8 ø \xc3\xb8 ø ø LATIN SMALL LETTER O WITH STROKE
U+00F9 ù \xc3\xb9 ù ù LATIN SMALL LETTER U WITH GRAVE
U+00FA ú \xc3\xba ú ú LATIN SMALL LETTER U WITH ACUTE
U+00FB û \xc3\xbb û û LATIN SMALL LETTER U WITH CIRCUMFLEX
U+00FC ü \xc3\xbc ü ü LATIN SMALL LETTER U WITH DIAERESIS
U+00FD ý \xc3\xbd ý ý LATIN SMALL LETTER Y WITH ACUTE
U+00FE þ \xc3\xbe þ þ LATIN SMALL LETTER THORN
U+00FF ÿ \xc3\xbf ÿ ÿ LATIN SMALL LETTER Y WITH DIAERESIS
\ No newline at end of file
...@@ -41,7 +41,7 @@ import string ...@@ -41,7 +41,7 @@ import string
b = checkstring('åøæ') b = checkstring('åøæ')
print(b) print(b)
''' '''
'''
with open('./test','wb') as file: with open('./test','wb') as file:
int2 = int('78') int2 = int('78')
file.write(int2.to_bytes(2,'little')) file.write(int2.to_bytes(2,'little'))
...@@ -70,7 +70,7 @@ for i in range(len(tekst)): ...@@ -70,7 +70,7 @@ for i in range(len(tekst)):
print(array) print(array)
print(''.join(map(chr, arr))) print(''.join(map(chr, arr)))
exit() exit()
'''
'''string_to_test = 'abå' '''string_to_test = 'abå'
def test(): def test():
...@@ -80,3 +80,29 @@ test()''' ...@@ -80,3 +80,29 @@ test()'''
#å=Ã¥ Å= #å=Ã¥ Å=
'''with open('./file_cleaning') as file:
tekst = file.read()
tekst = tekst.split('\n')
str = ''
for i in tekst:
i = i.split()
str += i[1]
print(str)'''
extended_string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
print(string.printable)
print(extended_string)
a = "ø"
for i in a:
if i in string.printable:
print("ascii")
elif i in extended_string:
print("not ascii")
else:
print("nor")
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment