def name_unicode(ucs):
    """Return 7-bit ascii printable of any string. """
    bits = ord(ucs)
    if 32 <= bits <= 126:
        rep = chr(bits)
    elif bits == 127:
        rep = '^?'
    elif bits < 32:
        rep = '^' + chr((bits & 127 | 32) + 32)
    else:
        rep = '\\x{:02x}'.format(bits)
    return rep
