Skip to content

Some characters cause glitches #750

Closed

Description

@nagisa

Trying entering some characters, for example U+1F603, U+1F60A or U+1F612 either by keyboard (compose sequences) or copy-paste does not show the character (entering one between quotes does work though, still with some glitches).

A screenshot

Some breakdown. First of all, for first and second examples some trailing white space was entered. For every character entered after the smile, quote before the smile is duplicated, but interestingly enough – echo is not. In the last example, smile does not appear at all (but was inserted at the beginning). Entering text after it is possible, but deleting does not respond with expected feedback (characters from internal buffer are cleared as far as I observed).

sh and bash obviously work fine in same terminal emulator.

I suspect the unicode library fish uses (does fish use one?) – it might not support any unicode characters outside BMP and SMP planes.

Activity

  1. sugar700 commented on May 16, 2013

    @sugar700
    Contributor

    Interesting, considering fish supports SMP perfectly fine.

    glitchmr@pineapple ~> echo 𝌠
    𝌠

    In fact, 😃 itself belongs to SMP. It's near the SMP end, but still in SMP.

    From interest, I have decided to check zsh syntax highlighting (yes, it also has syntax highlighting, as a plugin - it's worse than syntax highlighting in fish, but it's usable).

    glitchmr@pineapple ~> echo 𝌠
    𝌠
    glitchmr@pineapple ~> echo <0001f603>
    😃

    Huh? Why zsh hasn't even tried to render 😃? Hmmm... 𝌠 is Unicode 4.0, and 😃 is Unicode 6.0. Could it be that wcwidth() doesn't recognize Unicode 6.0.

    Perhaps fish could be changed to not even try to render unknown characters, just like zsh does (wcwidth should return -1 in that case). It works in dumb shells, like bash, but fish actually does complex math on characters, and needs to know their width. Certain characters, like fullwidth characters need more than one character to be written correctly.

    Indeed, it seems that fish never checks the return value of wcwidth, and as the result, it removes 1 character, causing craziness. I think that fish instead should print <0001f603> or something instead. Or assume the length is 1, but that sounds dangerous.

  2. ridiculousfish commented on Jun 9, 2013

    @ridiculousfish
    Member

    @nagisa , which terminal emulator are you using? I can't reproduce in Apple's Terminal app, though iTerm has lots of issues

  3. nagisa commented on Jun 9, 2013

    @nagisa
    ContributorAuthor

    It's gnome-terminal, so should be reproducible in any terminal based on VTE. There's lot of those in linux world. If you can't reproduce it in any terminal emulators not using VTE, it might be an issue with VTE though.

  4. 1player commented on May 7, 2015

    @1player

    @ridiculousfish does also happen on KDE's Konsole terminal, which is not based on VTE.

    I've been trying to write echo 🍅 and the tomato character does not show up, even though running the command gives the expected output. Also, next time I write 'echo' and I'm autosuggested the above command, the whole line gets garbled until I remove it from the history.

    Can reproduce on VTE-based Terminator and non-VTE Konsole terminal emulators. Bash is not affected.

  5. Ninja3047 commented on Jul 20, 2015

    @Ninja3047

    +1 for this issue, I have tried on both st and urxvt so it's definitely a fish issue.

  6. zanchey commented on Jul 20, 2015

    @zanchey
    Member

    This might be better since #2217 got merged; have you had a chance to try on a version newer than 2.2.0-65-ge7273e1 (i.e. built from master)?

  7. faho commented on Jul 20, 2015

    @faho
    Member

    I tested with 2.2.0.r55.g97edc96 (i.e. before 2217) and 2.2.0.r70.gdd4639e (after 2217), and I don't get a meaningful change. (Unfortunately I can't create a screenshot because of a bug in my screenshotting utility, will try to track that down)

  8. krader1961 commented on Jun 19, 2016

    @krader1961
    Contributor

    I cannot reproduce this using a fish built from git head as of this comment. There have been a ton of changes related to how locales and unicode are handled since this issue was opened. Or even since the last update 11 months ago. It seems reasonable to conclude it has been fixed so I'm closing it. If someone can still reproduce using a fish built from current source feel free to reopen.

  9. z3ntu commented on Jul 20, 2016

    @z3ntu
    Contributor

    @krader1961 I don't know if this is the exact same problem, but the newest git version still doesn't work with the characters üöä as expected. Video demonstration is here: https://youtu.be/vxAy0isw9Qc
    I am using Konsole with the fish-git AUR (Arch Linux) package which I just compiled.

  10. faho commented on Jul 20, 2016

    @faho
    Member

    @z3ntu: This works for me, also with Konsole, also on Arch. What's your locale? Does this happen without history (try sh -c 'env HOME=$(mktemp -d) fish')?

  11. reopened this on Jul 20, 2016
  12. z3ntu commented on Jul 20, 2016

    @z3ntu
    Contributor

    Yes, same behaviour without history.

    $ locale
    locale: Cannot set LC_ALL to default locale: No such file or directory
    LANG=en_US.UTF-8
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC=en_DE.UTF-8
    LC_TIME=en_DE.UTF-8
    LC_COLLATE=C
    LC_MONETARY=en_DE.UTF-8
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER="en_US.UTF-8"
    LC_NAME="en_US.UTF-8"
    LC_ADDRESS="en_US.UTF-8"
    LC_TELEPHONE="en_US.UTF-8"
    LC_MEASUREMENT=en_DE.UTF-8
    LC_IDENTIFICATION="en_US.UTF-8"
    LC_ALL=
    

    Yes, I know, that en_DE.UTF-8 is neither a valid X11 locale nor does it actually exist somehow on my system. But I want to have my system on English and my formats in German and that's why KDE sets my locale to this weird frankenstein monster of a locale.

  13. faho commented on Jul 20, 2016

    @faho
    Member

    Yes, I know, that en_DE.UTF-8 is neither a valid X11 locale nor does it actually exist somehow on my system. But I want to have my system on English and my formats in German and that's why KDE sets my locale to this weird frankenstein monster of a locale.

    That's the issue. When I set any locale variable to "en_DE.UTF-8", it starts failing. I'm guessing fish's setup here fails without an error. @krader1961: Can you confirm?

    While I can only suggest, @z3ntu, that you set your locale variables to something sensible, as far as I can see we should still be able to read and echo characters properly as long as LC_CTYPE (or if that is unset LANG or LC_ALL) is set properly.

  14. z3ntu commented on Jul 20, 2016

    @z3ntu
    Contributor
    LC_CTYPE="en_US.UTF-8"
    

    Isn't it set correctly? Btw do you know how you can fix these en_DE things but retain the german formats in KDE?
    EDIT: Same behaviour on my server with the following locale settings:

    $ locale
    LANG=
    LC_CTYPE="POSIX"
    LC_NUMERIC="POSIX"
    LC_TIME="POSIX"
    LC_COLLATE="POSIX"
    LC_MONETARY="POSIX"
    LC_MESSAGES="POSIX"
    LC_PAPER="POSIX"
    LC_NAME="POSIX"
    LC_ADDRESS="POSIX"
    LC_TELEPHONE="POSIX"
    LC_MEASUREMENT="POSIX"
    LC_IDENTIFICATION="POSIX"
    LC_ALL=
    
  15. krader1961 commented on Jul 20, 2016

    @krader1961
    Contributor

    You cannot set any of the locale env vars to invalid values. Doing so causes the libc locale subsystem to fallback to a single-byte locale. That in turn causes fish to incorrectly calculate how many columns (cells) are taken up on the terminal by those wide characters. Since your terminal is still decoding the UTF-8 sequences into wide characters but fish is no longer doing so you see the behavior you observed.

    This is really obvious on BSD systems. I cut and pasted your locale vars into a script, exported them, then started a new fish instance. Within that instance I ran the locale command. Here is what it output:

    LANG="en_US.UTF-8"
    LC_COLLATE="C"
    LC_CTYPE="C"
    LC_MESSAGES="C"
    LC_MONETARY="C"
    LC_NUMERIC="C"
    LC_TIME="C"
    LC_ALL=
    

    On Ubuntu (and presumably all GNU Linux systems) the output of locale obscures the problem:

    locale: Cannot set LC_ALL to default locale: No such file or directory
    LANG=en_US.UTF-8
    LANGUAGE=en_US:
    LC_CTYPE=en_US.UTF-8
    LC_NUMERIC=en_DE.UTF-8
    LC_TIME=en_DE.UTF-8
    LC_COLLATE=C
    LC_MONETARY=en_DE.UTF-8
    LC_MESSAGES=en_US.UTF-8
    LC_PAPER=en_US.UTF-8
    LC_NAME=en_US.UTF-8
    LC_ADDRESS=en_US.UTF-8
    LC_TELEPHONE=en_US.UTF-8
    LC_MEASUREMENT=en_DE.UTF-8
    LC_IDENTIFICATION=en_US.UTF-8
    LC_ALL=
    

    However, notice the first line of output. That's essentially telling you that you can't expect sane behavior given your combination of locale vars. On both systems fish treats each byte of those multibyte UTF-8 sequences as an individual character because that's what the libc locale subsystem is doing.

    I can't explain why KDE isn't exhibiting weird behavior. Perhaps it's using a different locale API than the one in libc.

    P.S., In the future please use asciinema rather than youtube videos.

  16. z3ntu commented on Jul 21, 2016

    @z3ntu
    Contributor

    image
    This is how my KDE "Formats" settings window looks... I really don't know why it does this weird stuff...
    EDIT: Finally fixed it.
    image
    Whatever the format nds_DE should be, uncommenting this in the /etc/locale.gen file and running locale-gen fixed it. Thanks for the help!

    Another EDIT: I finally found a non "Low German" (weird language ^^) setting for Austria. I actually only found these weird ones, as I was searching for "German" (as my system is english) but it is called "Deutsch" and "Österreich"... So again thanks.

  17. locked as resolved and limited conversation to collaborators on Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions