I'm trying to display big ascii text with curses, but it only works in the Visual Studio Code terminal for some reason.
Visual Studio Code terminal displays the text correctly
But when I try to run the program in powershell it cuts off the start of the text for some reason, and when I run it in cmd, it just displays a square of question marks.
What's going on and how do I fix it?
main.py:
import os, curses, time
os.system('cls' if os.name == 'nt' else 'clear')
def main(stdscr):
stdscr.clear()
HEIGHT = curses.LINES
WIDTH = curses.COLS
logo = []
with open("logo.txt", mode="r", encoding="utf-8") as dataFile:
logo = dataFile.readlines()
for i in range(len(logo)):
stdscr.addstr(logo[i])
stdscr.refresh()
stdscr.getkey()
curses.wrapper(main)
logo.txt:
#
# ##
# ########## ## ######### ##### ####
# # # ## ## # # ## ## # ##
# # ## # ## ## ##
## ## # # ########## ## # ##
## ## #### ## # # # ## ## ###
# ## # # # # # ## ## ####
# ########### ## ## ####
########## # # # ## ## ## ##
# ## # # # ## ## # ##
# #### ## ## # ## ## ## ##
## # # # # ########## ## ## ## ##
## ## # ## ## # # ##### #####
# # # # ####
I tried debugging by addstr-inging different variations of "A" and "AAAAAAAAAAAAAAAAAAAAAAAA" instead the ascii font, which worked normally.
I also tried changing the text to become smaller, in case the text got looped or something in the powershell terminal, but the same problem persisted.
Lastly I tried removing the first character for the same reason. The cut-off point seemed to be the same place on the screen, with less text meaning less of the text could peek past the blacked out area.
utf-8encoded characters and compatibility. By swapping-fand-tin this:$ iconv -f iso-8859-1 -o utf-8 logo.txtI can go from displaying the above, to a block of?- back and forth. My understanding of the problem, based on this:: You need to set curses [affectingstdscr.addstr()] to appropriately render utf-8 characters regardless of environment. (Tested in Ubuntu Terminal)import sys;sys.stdout.reconfigure(encoding='utf-8')does the trick forstdoutin git Bash (terminal) on windows.#, I would have understood:cursesgives some comfort towmoveposition on the screen. Or if you used some fancy color (and didn't want to use almost universal but non-portable ANSI\033[...stuff).systemto callcls, when curses providesclearfor thart.