I have just started using Python, and I got a problem with non-english (Vietnamese in particularly) input. When I run this code:
# -*- coding: unicode-escape -*-
s = raw_input()
print(s)
s = "hiển thị 15 dòng"
print(s)
and from terminal I type extracly the same string, it printed like:
hiển thị 15 dòng
hi\xe1\xbb\x83n th\xe1\xbb\x8b 15 d\xc3\xb2ng
It also make differences in when I use these 2 type of strings in other function as I found the first one didn't work but the second one did. Would anyone give me some hints? Thank you!
printing Unicode strings, so even after you fix things (as Raniz's answer shows) you still may not get to see what you want. If you're on any *nix besides Mac OS X, your terminal probably can support Unicode strings, but Python 2 may still not guess the right encoding, causing similar problems…