yaml / pyyaml

Canonical source repository for PyYAML
MIT License
2.47k stars 507 forks source link

Can't seem to read emoji #790

Closed ValonVN0 closed 3 months ago

ValonVN0 commented 3 months ago

Hello,

Setting up a basic yml file, fetching text which contains an emoji, unfortunately when printing out that emoji (in this example a purple heart), it's printing "💜",

Now I've attempted to store the emoji tiself (which in notepad++ it shows the physical emoji) I've attempted unicode, etc, however it simply doesn't seem to print the emoji image itself (printing not being in console, just to clarify as I can't see that supporting them)

Am I perhaps missing something obvious here?

nitzmahone commented 3 months ago

Works fine here- I'd suspect you've got an encoding issue on the way in or the way out- you never said what you were trying to display it with or how you're getting the data in there, but at least on Linux, it works fine on typical consoles...

If it's Windows, a likely culprit is a missing or mismatched BOM in the file...

test.py:

import pathlib
import yaml

d = yaml.safe_load(pathlib.Path('test.yml').read_text())

print(d)

test.yml:

hello: 🙂

output:

(tmp-f96bebe8ac6109f) mdavis@mdavis-p1:~/.virtualenvs/tmp-f96bebe8ac6109f$ python test.py
{'hello': '🙂'}