Földes László wrote in post #1133627:

>> " sss\1\2abc\xAA sss ".force_encoding(Encoding::UTF_8).valid_encoding?3D> false
>
> If you don't need to recognize multi-byte characters then deep dive into
> the byte representation and search there:
>
>> " sss\1\2abc\xAA sss ".unpack("H*")
> => ["207373730102616263aa2073737320"]

one question from out of curiosity - How did you got to know, by looking t the final Array or string, that "616263" is actually "abc" ?