def to_binary(text, encoding='ascii'):
    """Return the binary representation of string (if not already binary)."""
    if not isinstance(text, bytes):
        text = text.encode(encoding)
    return text