OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Convert a string of characters to a list of byte-valued integers:

ImportString["ABCDE",{"Binary","Byte"}]

The format specification "Binary" can be omitted when importing elementary data types:

ImportString["ABCDE","Byte"]

Export pairs of integers and reals to a binary sequence of 8-bit integers and double-precision reals:

b = ExportString[ {{1,343.13}, {2,232.33}, {3,210.01}}, "Binary", "DataFormat"-> {"Integer8", "Real64"}]

Convert the previous output back to an array of numbers:

ImportString[ b,  "Binary", "DataFormat"-> {"Integer8", "Real64"}]

Verify that each number pair was converted to 1+8 bytes:

StringLength[b]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[BinaryRead, paclet:ref/BinaryRead])  ▪  (RefLink[BinaryReadList, paclet:ref/BinaryReadList])  ▪  (RefLink[BinaryWrite, paclet:ref/BinaryWrite])}, {Related Formats:  (RefLink[Bit, paclet:ref/format/Bit])  ▪  (RefLink[Byte, paclet:ref/format/Byte])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Basic Formats, paclet:guide/BasicFormats])}, {▪(RefLinkPlain[Importing & Exporting, paclet:guide/ImportingAndExporting])}})}})