0

I've been a happy user of Rich for Python for some time now, but recently started having issues where colors and special characters are not displayed properly anymore. Here is an example output of printing a Table in Powershell 7 (x64).

ÔöÅÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔö│ÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöô
Ôöâ Character Ôöâ Binary    Ôöâ
ÔöíÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔòçÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔöüÔö®
Ôöé A         Ôöé 0b1000001 Ôöé
Ôöé B         Ôöé 0b1000010 Ôöé
Ôöé C         Ôöé 0b1000011 Ôöé
Ôöé D         Ôöé 0b1000100 Ôöé
Ôöé E         Ôöé 0b1000101 Ôöé
ÔööÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔö┤ÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÿ

I did not change my Python or Rich version, and testing with older versions seems to yield the same result. So I expect the issue to be related to some Windows/Powershell configuration issues.

My problem is that I don't know what to look for, hence my question here. I suspected a misconfiguration for displaying Unicode characters like in this thread, but it doesn't seem to be the case:

PS C:\Users\Thrastylon> [char]0x3a9
Ω

Any pointers or explanation of what could be happening would be appreciated.


For reproducibility, here is the code I used to generate the table above:

from rich.console import Console
from rich.table import Table


def make_table(n: int):
    table = Table("Character", "Binary")
    start_ord = ord("A")
    for o in range(start_ord, start_ord + n):
        table.add_row(chr(o), bin(o))
    return table


if __name__ == "__main__":
    console = Console()
    table = make_table(n=5)
    console.print(table)
Thrastylon
  • 853
  • 7
  • 20
  • 1
    I can't speak for **Rich**, but this is what counts for the usual consoles: [Using UTF-8 Encoding (CHCP 65001) in Command Prompt / Windows Powershell (Windows 10)](https://stackoverflow.com/a/57134096/1701026) – iRon Feb 09 '23 at 10:42
  • 1
    That... worked. No idea what modified it from the previously working state, but I'm not going to complain. Thanks for the pointer! – Thrastylon Feb 09 '23 at 11:07

0 Answers0