Skip to contents

Cat raw data to the sink in columns with ASCII code

Usage

displayRawData(x, ncol = 4, col.wid = 4, address.len = 3, hex.upper = T)

Arguments

x

A vector of class raw to be displayed.

ncol

Number of columns of hexadecimal code to display.

col.wid

Width of each column (in bytes) to display.

address.len

Length of the hexadecimal address (in number of hexadecimal digits) to display.

hex.upper

logical value, to specify whether hexadecimals should be displayed in uppercase (TRUE, default) or lowercase (FALSE).

Value

The character string send to the sink is also returned by the function.

Details

As binary data is hard to decipher this function will cat raw data as hexadecimal code in columns, together with the relative (hexadecimal) address of the data and an ASCII translation of the data. Hexadecimals are shown in space separated columns for improved readability. Special characters are replaced by dots in the ASCII representation.

Raw data is padded with zeros at the end to fill remaining columns...

See also

Author

Pepijn de Vries

Examples

## Display some raw random data:
displayRawData(as.raw(sample.int(100)))
#> 0x000  51454F63 1C0C591D 2F606452 30571740  QEOc..Y./`dR0W.@
#> 0x010  0B1A0746 152A2936 3D3E230A 3C1B2262  ...F.*)6=>..<..b
#> 0x020  37342C0D 5B584453 0209615F 062D5A48  74,.[XDS..a_.-ZH
#> 0x030  4E211101 55334A10 1F433941 25082631  N...U3J..C9A..&1
#> 0x040  142E120E 49200F35 5038425E 47030456  ....I .5P8B^G..V
#> 0x050  18164C4B 19542B3B 5C285D3F 4D05321E  ..LK.T+;\(]?M.2.
#> 0x060  27243A13 00000000 00000000 00000000  '.:.............

## Display the full ASCII table:
displayRawData(as.raw(0:255))
#> 0x000  00010203 04050607 08090A0B 0C0D0E0F  ................
#> 0x010  10111213 14151617 18191A1B 1C1D1E1F  ................
#> 0x020  20212223 24252627 28292A2B 2C2D2E2F   .....&'()*+,-./
#> 0x030  30313233 34353637 38393A3B 3C3D3E3F  0123456789:;<=>?
#> 0x040  40414243 44454647 48494A4B 4C4D4E4F  @ABCDEFGHIJKLMNO
#> 0x050  50515253 54555657 58595A5B 5C5D5E5F  PQRSTUVWXYZ[\]^_
#> 0x060  60616263 64656667 68696A6B 6C6D6E6F  `abcdefghijklmno
#> 0x070  70717273 74757677 78797A7B 7C7D7E7F  pqrstuvwxyz{|}~.
#> 0x080  80818283 84858687 88898A8B 8C8D8E8F  €.‚ƒ„…†‡ˆ‰Š‹Œ.Ž.
#> 0x090  90919293 94959697 98999A9B 9C9D9E9F  .‘’“”•–—˜™š›œ.žŸ
#> 0x0A0  A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF   ¡¢£¤¥¦§¨©ª«¬.®¯
#> 0x0B0  B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF  °±²³´µ¶·¸¹º»¼½¾¿
#> 0x0C0  C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF  ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
#> 0x0D0  D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF  ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
#> 0x0E0  E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF  àáâãäåæçèéêëìíîï
#> 0x0F0  F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF  ðñòóôõö÷øùúûüýþÿ