3D-MOOD / vis4d /data /io /util.py
RoyYang0714's picture
feat: Try to build everything locally.
9b33fca
"""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)