Python 2 and 3 Compatibility

sage.misc.six.u(x)

Convert \(x\) to unicode, assuming UTF-8 encoding.

Python2 behaviour:

If input is unicode, returns the input.

If input is str (assumed to be utf-8 encoded), convert to unicode.

Python3 behaviour:

If input is str, returns the input.

If input is bytes (assumed to be utf-8 encoded), convert to unicode.

EXAMPLES:

sage: from sage.misc.six import u
sage: u("500 €")
u'500 \u20ac'
sage: u(u"500 \u20ac")
u'500 \u20ac'