From 6574a58e15e7bf5b17920d89e644cfd0b02fe162 Mon Sep 17 00:00:00 2001 From: berhsi Date: Fri, 26 Jul 2019 21:35:29 +0200 Subject: [PATCH] kodierung.py added kodierung.py provides any little functions around encoding or decoding from strings or bytes --- kodierung.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 kodierung.py diff --git a/kodierung.py b/kodierung.py new file mode 100644 index 0000000..33bb232 --- /dev/null +++ b/kodierung.py @@ -0,0 +1,26 @@ +import sys + +def byteorder(): + return sys.byteorder + +def standart_encoding(): + return sys.getdefaultencoding() + +def standart_ausgabeencoding(): + return sys.stdout.encoding() + +def string2bytes(text): + try: + bytestream = bytes(text, "utf-8") + except Exception as e: + print('string2bytes: error: {}'.format(e)) + return + return bytestream + +def bytes2string(bytes): + try: + text = str(bytes, "utf-8") + except Exception as e: + print('bytes2string: error: {}'.format(e)) + text = '' + return text