Problem description:
when i print to the terminal in python and i want to print text with a coloured background, for some reason it no longer colours the background, it works fine when i print something like “abc” however, when i print two spaces (" ") with coloured background, the background is not coloured.
this is very sad because a project i was working on to use the console and the print() statement to display graphics no longer works on replit.
Expected behavior:
the text " " should have a coloured background
Actual behavior:
the text does not get a coloured background
Steps to reproduce:
print some spaces (" “) with coloured background using f”\033[48;2;{r};{g};{b}m{char}"
Browser/OS/Device:
problem appears on all devices and browsers i tried it with
The reason why it is not showing the background color is because there is some checking of text to see if there is unnecessary spaces in the string (probably to reduce the amount of resources needed to print to the console).
You can use the unicode character \u00a0 after the spaces to stop that from happening.
this does sort of solve the problem however, when i print the Unicode characters it breaks sometimes and displays a bit of jumbled up escape code and some characters that cant be displayed, i ran into this same problem in my original version of the project that used the big block Unicode characters instead of a coloured background.
also some added info about the jumbled up characters:
the Unicode only breaks when it becomes coloured
using regular escape codes that dont use full rbg works fine with Unicode.