Dealing with terminal escape codes from on_stdout

I have a function that grabs output from on_stdout, but the data has escape sequences in it.

Example:

\27[K\27[10Acompiler/screenplain.vim\r

I’d like to extract just the data, minus all the escape codes, e.g.

compiler/screenplain.vim

Is there a standard way to parse this?

Thanks!