generated from mwc/lab_compression
Finished Compression Lab
This commit is contained in:
1
text_codecs/hello.txt
Normal file
1
text_codecs/hello.txt
Normal file
@@ -0,0 +1 @@
|
||||
Hello!
|
||||
@@ -1,12 +1,18 @@
|
||||
"This simple codec converts all text to Lowercase."
|
||||
from register import register_codec
|
||||
|
||||
def encode(text):
|
||||
text = text.lower()
|
||||
return text.encode("utf-8")
|
||||
result = ""
|
||||
|
||||
for char in text:
|
||||
if char.isalpha() or char == " ":
|
||||
if char not in "aeiou":
|
||||
result += char
|
||||
|
||||
return result.encode("utf8")
|
||||
|
||||
def decode(data):
|
||||
return bytes(data).decode("utf-8").lower()
|
||||
|
||||
from register import register_codec
|
||||
register_codec(encode, decode, "mycodec")
|
||||
text = bytes(data).decode("utf8")
|
||||
return text
|
||||
|
||||
register_codec(encode, decode, "mycodec")
|
||||
Reference in New Issue
Block a user