Those look a lot like terminal escape sequences, with the escape byte (0x1b
) missing. In many terminals, certain sequences of bytes have special effects, such as changing the color, moving the cursor, etc. For example, \x1b[3;1H
means "move the cursor to row 3, column 1" on VT100 or compatible terminals, which most terminals are. (The VT100 is long dead, but many terminal applications such as Terminal.app
, GNOME Terminal, and xterm
, still use those escape sequences.)
You might be getting the escape byte (0x1b
), but it's being filtered somehow. repr
helps here, as it shows you what is actually in your string. You can get a list of common escape sequences, too.