yamlfix
yamlfix copied to clipboard
Unexpected unicode escaping
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
------------------------------------------------------------------
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?
Is it possible the bug is in the ruyaml lib itself?
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 :)