How to remove weird chars in ruby/telnet output and log

Hi, all.

tried google, didn’t find any clue.

Short story is:
I’m using ruby/telnet to drive some linux/cli cmd for automation.

The output includes several chars like: “^M” or " \b\b\b\bb" or
\h\h \h\h\h\h\h"
I want to remove them from log and output, but not sure if it’s safe to
c = “” if c == “^M”

I’d like to hear from you guys.

Btw, when I use tcl/expect, their logs generate a lot of chars like this

Any one know why?