Why can python iterate over utf-8 strings but not emoticons?

Consider this:

s = u"おはよう"
print len(s)
for c in s: print c

Output signal

4

what i expect

Now with emojis:

s = u"hi 🏈"

Output

5
h
i

????
????

Why? How can i fix this? I used to look at different links, but could not plunge into it. Ideally, I would like to find a solution that works for both Japanese and emoticons, but if it is for ascii and emoticons, then Im fine with it too

+4
source share

Source: https://habr.com/ru/post/1669160/


All Articles