Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken non-Latin output #2992

Open
sergeevabc opened this issue Dec 14, 2023 · 15 comments
Open

Broken non-Latin output #2992

sergeevabc opened this issue Dec 14, 2023 · 15 comments

Comments

@sergeevabc
Copy link

sergeevabc commented Dec 14, 2023

Initial state

jq 1.7.1 on Windows 7 x64

Steps to reproduce

  • Unpack the app to C:\Проверка
    I use Cyrillic, but C:\Vögel or C:\Pájaros will do as well

  • Launch the app only to see the following output

    $ jq.exe
    jq - commandline JSON processor [version 1.7.1]
    
    Usage:  C:\Р?С?Р?Р?РчС?РєР°\jq.exe [options] <jq filter> [file...]
            C:\Р?С?Р?Р?РчС?РєР°\jq.exe [options] --args <jq filter> [strings...]
            C:\Р?С?Р?Р?РчС?РєР°\jq.exe [options] --jsonargs <jq filter> [JSON_TEXTS...]
               ^^^^^^^^^^^^^^^^
  • Changing codepage via chcp 866/1251/65001 does not help

Expected output

Usage:  C:\Проверка\jq.exe ...
           ^^^^^^^^
@wader
Copy link
Member

wader commented Dec 14, 2023

Hi, thanks for the report. I wonder if this is somehow related to #2961

Did it work correctly in previous versions? would be great if you could try 1.7 and 1.6

@sergeevabc
Copy link
Author

@wader, 1.7rc-2 has no such bug, but it's already present in 1.7.

@wader
Copy link
Member

wader commented Dec 14, 2023

@sergeevabc Ok thanks, that is very useful

Changes jq-1.7rc2...jq-1.7

This commit sticks out 11c528d

@sergeevabc
Copy link
Author

@wader, I'm ready to test x64 windows binary without that commit if you compile and attach it to your next message right here (as .zip since Github does not allow .exe)

@wader
Copy link
Member

wader commented Dec 14, 2023

Thanks for the offer. We probably still want to call setlocale to support localised date formats etc. So i think me or someone else has to get a proper windows development setup to be able to look into this.

@sergeevabc
Copy link
Author

sergeevabc commented Dec 14, 2023

@wader, also I believe it's better from UX standpoint to omit paths when displaying the manual, because paths in this case, sometimes quite long,1 create a distracting noise and make it hard to read on small (e.g. laptop) screens.

Examples without paths

$ 7z.exe
7-Zip 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20
Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]

$ age.exe
Usage:
    age [--encrypt] (-r RECIPIENT | -R PATH)... [--armor] [-o OUTPUT] [INPUT]
    age [--encrypt] --passphrase [--armor] [-o OUTPUT] [INPUT]
    age --decrypt [-i PATH]... [-o OUTPUT] [INPUT]

$ aria2c.exe
Specify at least one URL.
Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE | METALINK_FILE] ...

$ ffmpeg.exe
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile} ...

$ magick.exe
Usage: magick.exe [ {option} | {image} ... ] {output_image}

$ rustic.exe
rustic - fast, encrypted, deduplicated backups powered by Rust
Usage: rustic.exe [OPTIONS] <COMMAND>

$ xxhsum.exe
xxhsum.exe 0.8.2 by Yann Collet
Print or verify checksums using fast non-cryptographic algorithm xxHash
Usage: xxhsum.exe [options] [files] ...

Footnotes

  1. Compare jq.exe and C:\Resources\Software\Portable\Console\jq.exe mentioned multiple times.

@wader
Copy link
Member

wader commented Dec 14, 2023

Hmm that is also a bit strange. It uses argv[0] for the program name which usually i think is up to the program running the command (the shell in this case) to provide as argument zero. Feels like there is some indirection going on? for me on macOS it print this.

$ jq
jq - commandline JSON processor [version 1.7]

Usage:	jq [options] <jq filter> [file...]
	jq [options] --args <jq filter> [strings...]
	jq [options] --jsonargs <jq filter> [JSON_TEXTS...]

....

$ /opt/homebrew/bin/jq
jq - commandline JSON processor [version 1.7]

Usage:	/opt/homebrew/bin/jq [options] <jq filter> [file...]
	/opt/homebrew/bin/jq [options] --args <jq filter> [strings...]
	/opt/homebrew/bin/jq [options] --jsonargs <jq filter> [JSON_TEXTS...]
....

Same with older versions?

@sergeevabc
Copy link
Author

sergeevabc commented Dec 14, 2023

@wader, that annoying thing related to displaying the manual with full paths exists in JQ for Windows since day one, at least it is true for 8 releases between 1.7.1 and 1.3.

@nicowilliams
Copy link
Contributor

jq only supports UTF-8 input and output, which means that on Windows you must use the UTF-8 code page.

@nicowilliams
Copy link
Contributor

nicowilliams commented Jan 16, 2024

image

chcp 65001 did make it work for me (this is on Windows 11).

@sergeevabc
Copy link
Author

sergeevabc commented Jan 17, 2024

@nicowilliams, you've checked another part of JQ output, not the one I reported.

Do the following to reproduce:

  • Start -> Run -> cmd.exe
  • Type C:\Проверка\jq-win64.exe and execute (mind the folder part)

2024-0117-0458 jq 171 chcp 65001

@nicowilliams
Copy link
Contributor

Ah, OK, I see it.

@nicowilliams
Copy link
Contributor

Maybe we need to SetConsoleMode() earlier?

@wader
Copy link
Member

wader commented Jan 24, 2024

As i'm hopeless encoding nerd i follow the #utf8 tag on mastodon and happen to see this https://fosstodon.org/@zirias@techhub.social/111810376715194784 the linked commit looks a bit interesting

@sergeevabc
Copy link
Author

Err… Hello?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants