Adds logging in light stuff, minor changes in config/string.
[python_utils.git] / string_utils.py
index 623ae45f03e6eb12c608f966b421ba9c5495b0e9..a6a2da3155fcf312e9a9bc21ecd94f26141b4fcb 100644 (file)
@@ -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'
         )
     )