I have a subprocess command that outputs some characters such as \'\\xf1\'. I\'m trying to decode it as utf8 but I get an error.
s = \'\\xf1\'
s.decode(\'utf
My understanding is that latin1 is a subset of utf8.
Wrong. Latin-1, aka ISO 8859-1 (and sometimes erroneously as Windows-1252), is not a subet of UTF-8. ASCII, on the other hand, is a subset of UTF-8. ASCII strings are valid UTF-8 strings, but generalized Windows-1252 or ISO 8859-1 strings are not valid UTF-8, which is why s.decode('UTF-8') is throwing a UnicodeDecodeError.