jira-cli icon indicating copy to clipboard operation
jira-cli copied to clipboard

jira issue view does not respect locale

Open realtime-neil opened this issue 4 years ago • 4 comments

Describe the bug jira issue view prints non-ascii characters forbidden by the current locale.

Please provide following details

  1. 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")
    
  2. Are you using Jira cloud or on-premise jira server? Also mention the version for on-premise installation.
    cloud
    
  3. What operating system are you using? Also mention version.
    ubuntu 18.04
    
  4. 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 avatar Nov 23 '21 17:11 realtime-neil

@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 avatar Nov 23 '21 17:11 ankitpokhrel

@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.

realtime-neil avatar Nov 23 '21 18:11 realtime-neil

Thanks for the details @realtime-neil, that was helpful! I will fix it in the next iteration.

ankitpokhrel avatar Nov 23 '21 21:11 ankitpokhrel

@ankitpokhrel jira issue list is also affected:

$ LC_ALL=C jira issue list --plain | tr -d '\000-\177' | wc 
      0       0      42

realtime-neil avatar May 19 '22 23:05 realtime-neil