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

Tried aprint("rand") from docs and got warning "[Warning] 'rand' is not printable in this environment." #106

Closed
Pyroseza opened this issue Jan 21, 2020 · 8 comments
Milestone

Comments

@Pyroseza
Copy link

Description

Tried aprint("rand") from docs README.md and got warning [Warning] 'rand' is not printable in this environment. seems more like an error cos I don't get any output other than the warning.

Steps/Code to Reproduce

from art import  *
aprint("rand")

Expected Behavior

one of the following at least

>>> aprint("butterfly") # print art
Ƹ̵̡Ӝ̵̨̄Ʒ 
>>> aprint("happy") # print art
 ۜ\(סּںסּَ` )/ۜ
>>> aprint("love_you",number=1,text="test")  # 2-part art
»-(¯`·.·´¯)->test<-(¯`·.·´¯)-« 
>>> aprint("random") # random 1-line art mode
'(っ◕‿◕)っ '
>>> aprint("rand")   # random 1-line art mode
't(-_-t) '

Actual Behavior

[Warning] 'rand' is not printable in this environment.

Operating System

Windows 10 Pro

Python Version

3.8.1

ART Version (Use : art.__version__)

4.4

@sepandhaghighi
Copy link
Owner

@Pyroseza Hi
Would you please give us more information about your environment(CMD,PowerShell and ...)?

@Pyroseza
Copy link
Author

Hi @sepandhaghighi, I am using gitbash (mingw64)

@sepandhaghighi
Copy link
Owner

It seems git bash does not support all 1-Line arts.
We will filter Non-ASCII arts for rand mode in a future release

@Pyroseza
Copy link
Author

Interesting... thanks for the feedback, looking forward to the future release

@Pyroseza
Copy link
Author

Hi there, I’ve just done some reading up and found that mingw does not start up in UTF-8 but it can be both configured in the settings and it can be configured in memory for the current session using an environment variable LANG='C.UTF-8'

My suggestion is to set this variable if it is not set, then output the characters, I don’t know if this will work for sure but more can be seen here: https://stackoverflow.com/a/36692549

I’ll be testing this shortly and confirm if it works or not, if not I will do a little more research on my side.

@Pyroseza
Copy link
Author

So bad news that did not work for me, looks like mingw64 (a.k.a. git bash) does not play nice when outputting unicode chars. I did confirm that it works great in powershell.

@Pyroseza
Copy link
Author

I found a solution but not the preferred solutio, it seems to be the way that python is launched without a UTF-8 encoding for IO, it launches windows' 'cp-1252'.

I found that if I set this particular environment variable PYTHONIOENCODING=utf-8 before running my script it works perfectly, if I try set it inside the script it does not work at all.

Here is my proof it works:

$ PYTHONIOENCODING=utf-8 py.exe -3 aprint.py
\(◑д◐)>∠(◑д◐)
$ PYTHONIOENCODING=utf-8 py.exe -3 aprint.py
(ᾢȍˬȍ)ᾢ ļ ļ ļ ļ ļ

This is where I found the solution:
https://stackoverflow.com/questions/4374455/how-to-set-sys-stdout-encoding-in-python-3

I still think there must be a way to set this programmatically from your lib... I'm sure of it, or at least something similar...

@sepandhaghighi
Copy link
Owner

sepandhaghighi commented Jan 23, 2020

@Pyroseza
Thanks for your effort.
Changing PYTHONIOENCODING environment variable is not a stable solution, because it may effect other programs and also is not applicable in all environments.
I think the best solution is filtering Non-ASCII 1-line arts for rand mode.

@sepandhaghighi sepandhaghighi added this to the art 4.6 milestone Jan 23, 2020
sepandhaghighi added a commit that referenced this issue Feb 7, 2020
sepandhaghighi added a commit that referenced this issue Feb 7, 2020
sepandhaghighi added a commit that referenced this issue Feb 8, 2020
sepandhaghighi added a commit that referenced this issue Feb 8, 2020
sepandhaghighi added a commit that referenced this issue Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants