yamlfix icon indicating copy to clipboard operation
yamlfix copied to clipboard

Unexpected unicode escaping

Open alessio-b2c2 opened this issue 2 years ago • 3 comments

Description

When using this configuration, unicode characters are printed using the escape sequence, rather than the unicode characters itself:

quote_basic_values=true
quote_representation='"'

Steps to reproduce

Run:

echo "a: 📈" | YAMLFIX_quote_basic_values=true YAMLFIX_quote_representation='"' yamlfix -  2>/dev/null

Current behavior

---
a: "\U0001F4C8"

Desired behavior

---
a: "📈"

Environment

python -c "import yamlfix.version; print(yamlfix.version.version_info())"
------------------------------------------------------------------
     yamlfix: 1.8.1
     Python: 3.10.9
     Platform: macOS-13.2-x86_64-i386-64bit
------------------------------------------------------------------

alessio-b2c2 avatar Feb 15 '23 09:02 alessio-b2c2

Interesting bug, thanks for reporting it @alessio-b2c2 . As a side note, the next executions don't trigger the bug, only the combination of those two configuration options:

echo "a: 📈" | YAMLFIX_quote_representation='"' yamlfix -  2>/dev/null 
echo "a: 📈" | YAMLFIX_quote_basic_values=true  yamlfix -  2>/dev/null 
echo "a: 📈" | yamlfix -  2>/dev/null 

I'm afraid I won't have time to fix this bug in the short future, will you be able to make a pull request to fix it?

lyz-code avatar Feb 16 '23 09:02 lyz-code

Is it possible the bug is in the ruyaml lib itself?

alessio-b2c2 avatar Feb 16 '23 09:02 alessio-b2c2

Maybe, but I don't think so because only one combination of yamlfix configuration parameters does raise the bug and we use ruyaml on all the cases. I don't remember very well the involved code so don't take my word very serious :)

lyz-code avatar Feb 17 '23 10:02 lyz-code