schoon
schoon

Reputation: 3324

Why does Python print print some emoticons but not others?

I'm printing a dataframe in Python 2.7/Ubuntu 14:

from pandas import *
import math, numpy

print DataFrame(com).fillna(0)

which gives lots of output like the following:

enter image description here

My questions is: why do some emoticons display correctly whereas some display as rectangles with hex characters in them?

Upvotes: 1

Views: 133

Answers (2)

jfs
jfs

Reputation: 414625

The output shows that python have printed all 6 emoticons successfully but your environment (font) can't display them i.e., the issue can be fixed without changing the code by updating the settings (choosing a different font)

$ python2 -c "for codepoint in range(0x1f63f, 0x1f645): print unichr(codepoint)"
😿
πŸ™€
πŸ™
πŸ™‚
πŸ™ƒ
πŸ™„

Note: U+1F643 UPSIDE-DOWN FACE and U+1F644 FACE WITH ROLLING EYES are introduced only in Unicode 8.0 standard (Released: 2015 June 17)β€”it is likely that most fonts do not support them. You could install Glyphs above the Unicode Basic Multilingual Plane to see the glyphs. Here's how it looks like in my terminal:

emoticons [U+1f63f-U+1f644] on Ubuntu

On the phone:

emoticons [U+1f63f-U+1f644] on iOS

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799120

Because you don't have any font that includes those glyphs, or for whatever reason the font substitution engine on your system has decided to not pull in the glyphs from another font. The missing characters were added in Unicode 7.0 and so it is likely that no font on your system has glyphs for them yet.

Upvotes: 2

Related Questions