<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fmt_text(text):
 """ convert characters that aren't printable to hex format """

    PRINTABLE_CHAR = set(
        list(range(ord(' '), ord('~') + 1)) + [ord('\r'), ord('\n')])
    newtext = ("\\x{:02X}".format(
        c) if c not in PRINTABLE_CHAR else chr(c) for c in text)
    textlines = "\r\n".join(l.strip('\r')
                            for l in "".join(newtext).split('\n'))
    return textlines