Closed non-descriptive closed 1 year ago
oh! this is very interesting. thank you so much for filing!
the logic for the "bubbles" is very naive at the moment (https://github.com/axodotdev/axolotlsay/blob/main/src/main.rs#L14). the byte length of non-ascii symbols is more than 1 and as a result that means we are generating too many!
i can take a look at calculating this in a bit but if you are interested in tackling it i would welcome a contribution- i think this stack overflow article has a pretty good explanation of the issue and some hints at tools to use to solve it https://stackoverflow.com/questions/46290655/does-rusts-string-have-a-method-that-returns-the-number-of-characters-rather-th
at least partially solved by #2 - i'll leave it up to @non-descriptive if they want to close this and file new more specific issues, or leave this one and explain some of the further issues/improvements :)
Terminals can do many things, but when it comes to character encoding things getting complicated.
unicode-width
solves this kind of problem, but partially. I think it assumes that sequences of characters usually don't change width much and fails to measure other kind of input - smileys like ¯\_( ͡° ͜ʖ ͡°)_/¯
or other table flippers. It basically combines width problem with combining characters problem. And no amphibian can measure this nasty input width for any kind of terminal out there and they are many. Not sure if anyone can fix it, but you can dare.
For some reason bubble top and bottom parts longer than needed, when axolotl says in non-ascii characters.