String
Background & Context
-
- Arbitrary binary data represented as a Wolfram Language string.
- Used for importing or exporting entire raw binary data.
Import & Export
- Import ["file","String"] imports a file as a raw string, representing each byte of the file as the character corresponding to FromCharacterCode [byte].
- Export ["file",str,"String"] exports a Wolfram Language string of characters to a binary file. Characters with an encoding greater than 255 are converted to their ASCII representation before exporting.
- The format "String" must be explicitly specified.
- ExportString [expr,"format"] and Import [Export ["tmp",expr,"format"],"String" ] return the same expression.
- Import ["file","String"] reads any binary file, representing its raw content as a Wolfram Language string object.
- Export ["file",str,"String"] exports a Wolfram Language string to a file.
- No character encoding transformations are performed when importing or exporting as "String".
- Export ["file",expr,"String"] exports a textual representation of expr.
- See the following reference pages for full general information:
-
CloudImport , CloudExport import from or export to a cloud objectImportString , ExportString import from or export to a stringImportByteArray , ExportByteArray import from or export to a byte array
Examples
open all close allBasic Examples (1)
Read an arbitrary binary file and return it as a raw Wolfram Language string:
Show the first bytes of the result, which contain unprintable characters:
Convert the string that represents the file "ocelot.jpg" to graphics:
Scope (1)
Import binary data and compute an MD5 checksum:
Related Guides
History
Introduced in 2004 (5.1) | Updated in 2007 (6.0)