Spaces:
Running
on
Zero
Running
on
Zero
File size: 521 Bytes
9b33fca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
"""Data I/O Utilities."""
from __future__ import annotations
import sys
def str_decode(str_bytes: bytes, encoding: None | str = None) -> str:
"""Decode to string from bytes.
Args:
str_bytes (bytes): Bytes to decode.
encoding (None | str): Encoding to use. Defaults to None which is
equivalent to sys.getdefaultencoding().
Returns:
str: Decoded string.
"""
if encoding is None:
encoding = sys.getdefaultencoding()
return str_bytes.decode(encoding)
|