1 | initial version |
You can prefix your string with the letter u
to mark it as a unicode string, eg u'gömböc'
.
2 | No.2 Revision |
EDITED. My original answer was missing the point. This is maybe more a related discussion than an answer.
You can prefix your a string with the letter u
to mark it as a unicode string, eg u'gömböc'
.
Here is what I get in the Sage REPL.
sage: 'Erdős'
'Erd\xc5\x91s'
sage: u'Erdős'
u'Erd\u0151s'
This shows a difference in the escape codes used for accented characters.
Apparently @kcrisman's indication to use print
is the key to properly displaying unicode strings.
sage: print 'Erdős'
Erdős
sage: print u'Erdős'
Erdős
The role of the u
prefix is not so apparent here.
The u
is useful if you are using unicode escape codes in the string.
sage: print 'Erd\u0151s'
Erd\u0151s
sage: print u'Erd\u0151s'
Erdős
The other version:
sage: print 'Erd\xc5\x91s'
Erdős
3 | No.3 Revision |
EDITED. My original answer answer
You can prefix a string with the letter
u
to mark it as a unicode string, egu'gömböc'
.
was missing the point. This is not so helpful. The notes below are maybe more a related discussion than an a proper answer.
You can prefix a string with the letter u
to mark it as a unicode string.
If you are inputting unicode characters, this will affect how the string is encoded.
Here is what I get in the Sage REPL.
sage: 'Erdős'
'Erd\xc5\x91s'
sage: u'Erdős'
u'Erd\u0151s'
This shows a difference in the escape codes used for accented characters.
Apparently @kcrisman's indication to use print
is the key to properly displaying unicode strings.
sage: print 'Erdős'
Erdős
sage: print u'Erdős'
Erdős
The role of the u
prefix is not so apparent here.
The u
is useful if you are using unicode escape codes in the string.
sage: print 'Erd\u0151s'
Erd\u0151s
sage: print u'Erd\u0151s'
Erdős
The other version:
sage: print 'Erd\xc5\x91s'
Erdős