<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def xcode(text, encoding='utf8', mode='ignore'):
    '''
    Converts unicode encoding to str

    >>> xcode(b'hello')
    b'hello'
    >>> xcode('hello')
    b'hello'
    '''
    return text.encode(encoding, mode) if isinstance(text, str) else text