jira-cli
jira-cli copied to clipboard
jira issue view does not respect locale
Describe the bug
jira issue view prints non-ascii characters forbidden by the current locale.
Please provide following details
- JiraCLI Version:
$ go install github.com/ankitpokhrel/jira-cli/cmd/[email protected] && jira version (Version="dev", GitCommit="", GoVersion="go1.17.3", BuildDate="", Compiler="gc", Platform="linux/amd64") - Are you using Jira cloud or on-premise jira server? Also mention the version for on-premise installation.
cloud - What operating system are you using? Also mention version.
ubuntu 18.04 - What terminal are you using? Also mention version.
$ gnome-terminal --version # GNOME Terminal 3.28.2 using VTE 0.52.2 +GNUTLS -PCRE2
To Reproduce
$ LC_ALL=C jira issue view --plain FOOBAR-1000 2>/dev/null | tr -d '\000-\177' | wc -c
46
Expected behavior
$ LC_ALL=C jira issue view --plain FOOBAR-1000 2>/dev/null | tr -d '\000-\177' | wc -c
0
Screenshots not applicable
Additional context not applicable
@realtime-neil Is it only the emojis in plain mode that you want to get rid of? Or, are you expecting something else with LC_ALL=C opt? I am not sure how other tools behave in similar case.
@ankitpokhrel here's decent explanation about which characters are "allowed" by the C locale:
The C locale is a special locale that is meant to be the simplest locale. You could also say that while the other locales are for humans, the C locale is for computers. In the C locale, characters are single bytes, the charset is ASCII (well, is not required to, but in practice will be in the systems most of us will ever get to use), the sorting order is based on the byte values¹, the language is usually US English (though for application messages (as opposed to things like month or day names or messages by system libraries), it's at the discretion of the application author) and things like currency symbols are not defined.
-- https://unix.stackexchange.com/questions/87745/what-does-lc-all-c-do/87763#87763 , emphasis mine
tldr; print non-ascii characters if and only if the current locale supports it
If you want to print Emoji, then you should probably first check that the current locale's codeset supports it. E.g., en_US.UTF-8 would, but C (since it has no codeset) would not.
Thanks for the details @realtime-neil, that was helpful! I will fix it in the next iteration.
@ankitpokhrel jira issue list is also affected:
$ LC_ALL=C jira issue list --plain | tr -d '\000-\177' | wc
0 0 42