Don't try to re-encode a string unless it fails. When attempting to
re-encode first guess what the encoding might be, decode, then encode.