def to_byte_array(string: str) -> bytearray:
    """
    convert a string into a byte list. Skip all characters that are not in the range
    of ISO/IEC 8859-1 character set to avoid undefined behavior

    According to PEP3333, "Native" strings (which are always implemented using the type named str)
    that are used for request/response headers and metadata". The content content of native strings
    must be translatable to bytes via the Latin-1 encoding. HTTP does not support unicode.
    """
    byte_array = bytearray()
    for char in string:
        if ord(char) >= 256:
            continue
        else:
            byte_array.append(ord(char))
    return byte_array