I did it this way:
def toUnicodeEscape(text): oof = [] for i in text: oof.append(f'u00{hex(ord(i))[-2:]}') result = '\\' result += '\\'.join(oof) return result