Meaning of string representation of binary data

57 views Asked by At

Recently I faced with such string representation of binary-data: \xfa\xd4\xe4d\x00\x00\x00\x00

It is string representation of little-endian UNIX timestamp (1692718330)

I understand that, for example, \xfa is string literal for hex number fa which is equivalent to 250 decimal number. But I'm wondering about how I need to understand d in \xe4d. I know that it stands for 0x64 (it is ASCII number of the character d) but why some of data in such string is represented as a hex literals but another as just character literals which should be perceived as a ASCII code.

1

There are 1 answers

0
RARE Kpop Manifesto On

output from non-gnu od ::

0000000        1692718330               0              10   
             
         372 324 344   d  \0  \0  \0  \0  \n                            
          372 324 344 144 000 000 000 000 012                            
           ?   ?   ?   d nul nul nul nul  nl                            
          250 212 228 100   0   0   0   0  10                            
           fa  d4  e4  64  00  00  00  00  0a                            

0000011

which you can reverse verify:

1692718330 BE : 0000000064E4D4FA | LE : xFA xD4 xE4 x64 x00 x00 x00 x00 

 1  $++NF = sprintf("BE : %.16X | LE : "\
                    "x%.2X x%.2X x%.2X x%.2X x%.2X x%.2X x%.2X x%.2X ",
             __ = $++_,
             __ % (_^= _+= ++_),
             int(__/_)%_,
             int(__/_/_)%_,
             int(__/_/_/_)%_,
             int(__/_/_/_/_)%_,
             int(__/_/_/_/_/_)%_,
             int(__/_/_/_/_/_/_)%_,
             int(__/_/_/_/_/_/_/_)%_) '