summaryrefslogtreecommitdiff
path: root/string_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'string_utils.py')
-rw-r--r--string_utils.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/string_utils.py b/string_utils.py
index 623ae45..a6a2da3 100644
--- a/string_utils.py
+++ b/string_utils.py
@@ -1461,10 +1461,14 @@ def to_bitstring(txt: str, *, delimiter='', encoding='utf-8', errors='surrogatep
>>> to_bitstring('test', delimiter=' ')
'01110100 01100101 01110011 01110100'
+ >>> to_bitstring(b'test')
+ '01110100011001010111001101110100'
+
"""
+ etxt = to_ascii(txt)
bits = bin(
int.from_bytes(
- txt.encode(encoding, errors),
+ etxt,
'big'
)
)