From 9ac30cfc22f3b6dc6be22ad96deef1b523fc26b2 Mon Sep 17 00:00:00 2001 From: jkissane2 Date: Thu, 2 Apr 2026 12:16:24 -0400 Subject: [PATCH] Finished Compression Lab --- text_codecs/hello.txt | 1 + text_codecs/mycodec.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 text_codecs/hello.txt diff --git a/text_codecs/hello.txt b/text_codecs/hello.txt new file mode 100644 index 0000000..05a682b --- /dev/null +++ b/text_codecs/hello.txt @@ -0,0 +1 @@ +Hello! \ No newline at end of file diff --git a/text_codecs/mycodec.py b/text_codecs/mycodec.py index e4be94e..fab00e9 100644 --- a/text_codecs/mycodec.py +++ b/text_codecs/mycodec.py @@ -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") \ No newline at end of file