def slip_encode_esc_chars(data_in):
    """Encode esc characters in a SLIP package.

    Replace 0xCO  with 0xDBDC and 0xDB with 0xDBDD.

     :type str data_in: str to encode
     :return: str with encoded packet
    """
    result = []
    data = []
    for i in data_in:
        data.append(ord(i))
    while len(data):
        char = data.pop(0)
        if char == 192:
            result.extend([219, 220])
        elif char == 219:
            result.extend([219, 221])
        else:
            result.append(char)
    return ''.join(chr(i) for i in result)
