forked from Krautspace/doorstatus
kodierung.py added
kodierung.py provides any little functions around encoding or decoding from strings or bytes
This commit is contained in:
parent
b830789f0e
commit
6574a58e15
1 changed files with 26 additions and 0 deletions
26
kodierung.py
Normal file
26
kodierung.py
Normal file
|
@ -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
|
Loading…
Reference in a new issue