Mathematica > Data Manipulation > Importing and Exporting > String >

String

Arbitrary binary data represented as a Mathematica string.
Used for importing or exporting entire raw binary data.
  • Using as the format specification, Import and Export can represent any file as a sequence of ordinary or special characters.
  • Import imports a file as a raw string, representing each byte of the file as the character corresponding to FromCharacterCode[byte].
  • Export exports a Mathematica string of characters to a binary file. Characters with an encoding greater than 255 are converted to their ASCII representation before exporting.
  • The format must be explicitly specified.
  • Import reads any binary file, representing its raw content as a Mathematica string object.
  • Export exports a Mathematica string to a file.
  • No character encoding transformations are performed when importing or exporting as .
  • Export exports a textual representation of expr.
  • See the reference pages for full general information on Import and Export.
Read an arbitrary binary file and return it as a raw Mathematica string:
Show the first bytes of the result, which contain unprintable characters:
Convert the string which represents the file "ocelot.jpg" to graphics:
Import binary data and compute a MD5 checksum:
Read an arbitrary binary file and return it as a raw Mathematica string:
In[1]:=
Click for copyable input
Show the first bytes of the result, which contain unprintable characters:
In[2]:=
Click for copyable input
Out[2]=
Convert the string which represents the file "ocelot.jpg" to graphics:
In[3]:=
Click for copyable input
Out[3]=
Import binary data and compute a MD5 checksum:
In[1]:=
Click for copyable input
Out[1]=
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF