Move shared coerce_terminal_encoding to common

Also, use (U instead of )U to designate G0, not G1 to cp437