in reply to Re: Datatype and pack/unpack
in thread Datatype and pack/unpack

Thank you people, for all your responses. Ok, so the "char" is just en eight-bit integer and there is no necessity to what this range of numbers represent, then why does my computer produce ABCDE from the example code?  $pack = pack ('c4', 65, 66, 67, 68); When I "pack" 65 by using a char type, I get A .. WHY WHY WHY .. It is just an eight-bit int why does it HAVE to end as an A?

Replies are listed 'Best First'.
Re^3: Datatype and pack/unpack
by Anonymous Monk on Mar 19, 2010 at 20:04 UTC
    As was mentioned above, The mapping of value 65 to the character "A", is just because you're using a computer that's configured for a character encoding that makes this true.

    If your machine was using EBCDIC, the value 65 would map to a Non-breaking Space.

    Your mapping of 65 to "A" is not much of a surprise because many modern character encodings are build as a superset of the 7 bit ASCII encoding. It's not uncommon to see folks using the "Latin" code pages that have this property, as does UTF-8. Any of these choices are common.

      Thanks .. I appreciate your kindness to take the time and respond.