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

Unicode characters are not supported #3

Open
Nevon opened this issue Oct 4, 2016 · 9 comments
Open

Unicode characters are not supported #3

Nevon opened this issue Oct 4, 2016 · 9 comments
Labels

Comments

@Nevon
Copy link

Nevon commented Oct 4, 2016

/ # ./root/bin/pokemonsay фывафва
 ________________ 
< ÑÑваÑва >
 ---------------- 
           \
            \
             \
              \
        ▄▄▄▄
       ▄▄  ▄▄▄ 
   ▄▄▄▄▄▄▄ ▄   
 ▄▄▄▄ ▄▄ ▄ ▄▄▄  ▄▄▄▄▄
 ▀ ▄  ▄▄▄ ▄▄ ▄▄▄▄▄   
  ▄▄▄▄▄▄▄ ▄▄▄ ▄▄▄   ▄▄
 ▄▄▄ ▄ ▄▄ ▄  ▄▄▄ ▄▄ ▄▄▄ 
  ▄▄▄▄▄ ▄ ▄ ▄▄ ▄▄ ▄ ▄ ▄▀
  ▀▀▀    ▄  ▀▄▄▄  ▄▄▄▀
       ▀▄▄▄▀    ▀▀▀

Rhyhorn

screen shot 2016-10-04 at 13 22 20

@xaviervia
Copy link

We tested this in docker with Alpine linux. echo and cowsay print the unicode characters just fine, so the issue seems to be coming from pokemonsay.

Great project btw, love it ❤️

@Nevon
Copy link
Author

Nevon commented Oct 4, 2016

Cross-posted this issue upstream, since it looks like the issue is in rossy/img2xterm#9

@possatti
Copy link
Owner

possatti commented Oct 4, 2016

Thanks for the support guys.

Funny thing, I am Brazilian but I have only tested with English text so far. But it's just like @Nevon said, it looks like an issue with img2xterm.

@possatti possatti added the bug label Oct 4, 2016
@possatti
Copy link
Owner

possatti commented Oct 6, 2016

I've been thinking about this and I think there's a way around the problem. It's not the most elegant solution, but I could remove binmode STDOUT, ":utf8"; from all cowfiles and pipe the output of cowsay to a sed process which will remove that warning line.

I went on to experiment with that. I removed the binmode thing and it worked. I've put the thing back again expecting it to not work... and it also worked. Suddenly I don't understand anything anymore, but mine is working with a clean repo. It's like I have done nothing, but it is working.

screenshot from 2016-10-06 08-54-26

I wish I've noticed what happened and I would come up with a solution, but I don't.

@xaviervia
Copy link

sed sounds like a beautiful solution to me. No need for more if it works. :shipit:

possatti added a commit that referenced this issue Oct 16, 2016
The `binmode STDOUT, ":utf8";` was removed from all `.cow` files.
And the warning `Wide character in print at [...]` is removed
using `sed`.
@possatti
Copy link
Owner

Guys, could you try the branch unicode. I think there is no need to install, just clone the repo and do ./pokemonsay.sh "こんにちは世界" a few times. I might have fixed the problem.

If you can, please test the master branch as well. Nothing changed on master, but I'm puzzled that I can't reproduce the problem anymore.

I'm sorry it took so long for me to take a look at this. It's my last year in college and things are really tough. xD

@Nevon
Copy link
Author

Nevon commented Oct 16, 2016

screen shot 2016-10-16 at 08 16 26

At first I figured maybe it was an issue with your expression, so I made one that might be a little more robust, but it's also failing. However, it is matching the text normally, so there's something fishy.

screen shot 2016-10-16 at 08 23 52

However, it works with a plain non-ansi nonsense cowfile:
screen shot 2016-10-16 at 08 26 36

Then I thought that maybe the warning was in stderr or something, so I tried combining the streams before doing the sed, but that didn't work either. Super weird.

Having never written Perl in my life, I have no idea if the following is correct, but I think the binmode(STDOUT, ":utf8"); should stay. The files are encoded as us-ascii, which is a subset of utf8, so we are expecting the output to be utf8. So I went the other direction and modified cowsay to basically tell it that anything and everything is utf8 and should be treated as such:

use utf8;
binmode STDOUT, ":utf8";
binmode STDERR, ":utf8";
binmode STDIN,  ":utf8";

But nope...

screen shot 2016-10-16 at 09 25 53

I'm sorry it took so long for me to take a look at this. It's my last year in college and things are really tough. xD

Don't kill yourself over it, man. It's a silly way to have pokemon in your terminal, not a cure for cancer.

@lookoutldz
Copy link

6 years gone. Did you solve the problem?

@JasonLamv-t
Copy link

6 years gone. Did you solve the problem?

8 years now. :)

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

No branches or pull requests

5 participants