convert char to byte representation

Grant Edwards grante at visi.com
Mon Oct 10 20:34:27 CEST 2005


On 2005-10-10, Larry Bates <larry.bates at websafe.com> wrote:

>> I am trying to xor the byte representation of every char in a string with
>> its predecessor. But I don't know how to convert a char into its byte
>> representation. This is to calculate the nmea checksum for gps data.

> ord(c) gives you decimal representation of a character.

While ord(c) is what the OP needs, it doesn't give a decimal
represention -- which I guess would be a string like "65" for
the ASCII characer "A".  What ord() gives you is an integer
object with the value of the character [which the hardware
stores in binary on all of the platforms I'm aware of].

-- 
Grant Edwards                   grante             Yow!  Hmmm... A hash-singer
                                  at               and a cross-eyed guy were
                               visi.com            SLEEPING on a deserted
                                                   island, when...



More information about the Python-list mailing list