def to_bytes(text, encoding: str='utf-8', errors: str='strict'):
    """Return the binary representation of `text`. If `text`
    is already a bytes object, return it as-is."""
    if not text:
        return b''
    if isinstance(text, bytes):
        return text
    return text.encode(encoding, errors)
