def rpr(s):
    """Create a representation of a Unicode string that can be used in both
    Python 2 and Python 3k, allowing for use of the u() function"""
    if s is None:
        return 'None'
    seen_unicode = False
    results = []
    for cc in s:
        ccn = ord(cc)
        if ccn >= 32 and ccn < 127:
            if cc == "'":
                results.append('\\')
                results.append(cc)
            elif cc == '\\':
                results.append('\\')
                results.append(cc)
            else:
                results.append(cc)
        else:
            seen_unicode = True
            if ccn <= 65535:
                results.append('\\u')
                results.append('%04x' % ccn)
            else:
                results.append('\\U')
                results.append('%08x' % ccn)
    result = "'" + ''.join(results) + "'"
    if seen_unicode:
        return 'u(' + result + ')'
    else:
        return result
