On 23Apr2019 20:35, Eli the Bearded <*@eli.users.panix.com> wrote:
In comp.lang.python, Chris Angelico <ros...@gmail.com> wrote:
Is there a more python-esque way to convert what should be plain
ascii
What does "plain ASCII" actually mean, though?
ASCII encoded binary data. ASCII is code points that fit in 7-bits
comprising the characters found on a typical 1970s US oriented
typewriter plus a few control characters.
[...]
but I would strongly recommend just
encoding and decoding regardless. Use text internally and bytes at the
outside.
That feels entirely wrong. I don't know what b'\x9A' means without
knowing the character set and character encoding. If the encoding is a
multibyte one, b'\x9A' doesn't mean anything on its own. That's why I
want to treat it as binary.
If you don't know the encoding then you don't know you're looking at a
hex digit. OTOH, if the binary data contain ASCII data then you do know
the encoding: it is ASCII.
If that is mixed with other data then you need to know where it
starts/stops in order to pull it out to be decoded. The overall data may
be a mix, but the bit you're pulling out is encoded text, which you
could decode.
Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list