jq
jq copied to clipboard
strftime produces corrupted characters in windows
Describe the bug
Using strftime
function in Windows produces unreadable symbols in console.
To Reproduce Taken from https://github.com/jqlang/jq/blob/693a7261e5ebccaf0c74fde0ac48700ba3d52f17/tests/optional.test#L16 and https://github.com/jqlang/jq/blob/693a7261e5ebccaf0c74fde0ac48700ba3d52f17/tests/jq.test#L1562:
$ echo 1435677542.822351 | jq "strftime(\"%A, %B %d, %Y\")"
"�������, ���� 30, 2015"
Using both windows 1251 and utf 8 encodings gives same corrupted output.
Expected behavior The output should be readable.
Environment (please complete the following information):
- OS and Version: Windows 10 x64
- jq version: jq-1.7-dirty
Additional context
Both files contain same test case.
Huh weird, possibly to pipe it thru hexdump -C
or possibly redirect to a file and attach? but maybe it will just show replacement characters hmm
Did you try chcp 65001
?
Huh weird, possibly to pipe it thru
hexdump -C
or possibly redirect to a file and attach? but maybe it will just show replacement characters hmm
Sure. Here it is: jq#2961.txt
echo 1435677542.822351 | jq "strftime(\"%A, %B %d, %Y\")" > jq#2961.txt
22efbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbd2c20efbfbdefbfbdefbfbdefbfbd2033302c2032303135220d0a
Did you try
chcp 65001
?
Yes, of course. Same for any codepage.
$ chcp 65001
$ echo 1435677542.822351 | jq "strftime(\"%A, %B %d, %Y\")"
"�������, ���� 30, 2015"
Managed to kind of produce it with wine (no windows dev setup atm) and jq-windows-amd64.exe
$ docker run --platform linux/amd64 -ti --rm debian:bookworm
$ apt-get update
$ apt-get install -y curl wine
$ curl -OLJ https://github.com/jqlang/jq/releases/download/jq-1.7/jq-windows-amd64.exe
# same with LC_ALL=ru_RU.UTF-8
$ LC_ALL=ru_RU.CP1251 wine jq-windows-amd64.exe -n '1435677542.822351 | strftime("%A, %B %d, %Y")'
<lots-of-warnings>
"???????, ???? 30, 2015"
$ LC_ALL=ru_RU.UTF-8 wine jq-windows-amd64.exe -n '1435677542.822351 | strftime("%A, %B %d, %Y")'
<lots-of-warnings>
"???????, ???? 30, 2015"
# default local (if i run locale is says "POSIX")
$ wine jq-windows-amd64.exe -n '1435677542.822351 | strftime("%A, %B %d, %Y")'
"Tuesday, June 30, 2015"
# swedish seems to work
$ LC_ALL=sv.SE.CP1251 wine jq-windows-amd64.exe -n '1435677542.822351 | strftime("%A, %B %d, %Y")'
"tisdag, juni 30, 2015"
No idea how compareable this is to a proper windows installation but maybe there is something with msys2 and some locales etc?
I wonder if we have to make stdout
binary on Windows. It seems like something is interpreting the output.
I can not reproduce the issue with jq from msys2 https://packages.msys2.org/base/mingw-w64-jq
$ echo 1435677542.822351 | jq "strftime(\"%A, %B %d, %Y\")"
"Tuesday, June 30, 2015"
No locale variable set, system language is US English.
Seems like non-latin characters are corrupted.