RawMemoryImport

RawMemoryImport[ptr,format]

imports raw memory from the pointer ptr with the specified format.

RawMemoryImport[format]

represents an operator form of RawMemoryImport that can be applied to an expression.

Details and Options

  • Supported values of ptr include RawPointer expressions and ManagedObject expressions whose values are pointers.
  • Supported values of format include:
  • "String"null-terminated string
    {"String",len}string of len bytes
    {"ByteArray",len}byte array of len bytes
    {"NumericArray",len}numeric array of len elements
    {"List",len}list of len elements
  • For "NumericArray" and "List" import formats, the element type is determined by the type of the input pointer ptr.
  • Supported options include:
  • CharacterEncoding "UTF-8"character encoding for strings

Examples

open allclose all

Basic Examples  (1)

Export a string as raw memory:

Import the raw memory as a list:

Scope  (4)

RawMemoryImport supports passing a managed pointer as its first argument:

It also supports passing a non-managed pointer:

Export a string as raw memory:

Import the raw memory as a "List":

Import the raw memory as a "ByteArray":

Import the raw memory as a "NumericArray":

Export a string as a raw memory:

For null-terminated strings, the length does not need to be specified:

Use RawMemoryImport in operator form:

Options  (1)

CharacterEncoding  (1)

Export a string with non-ASCII characters as raw memory:

Specify what CharacterEncoding should be used when importing a string:

Properties & Relations  (1)

RawMemoryExport is the inverse operation of RawMemoryImport:

Possible Issues  (1)

RawMemoryImport fails if the format is not supported:

Wolfram Research (2023), RawMemoryImport, Wolfram Language function, https://reference.wolfram.com/language/ref/RawMemoryImport.html.

Text

Wolfram Research (2023), RawMemoryImport, Wolfram Language function, https://reference.wolfram.com/language/ref/RawMemoryImport.html.

CMS

Wolfram Language. 2023. "RawMemoryImport." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RawMemoryImport.html.

APA

Wolfram Language. (2023). RawMemoryImport. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RawMemoryImport.html

BibTeX

@misc{reference.wolfram_2024_rawmemoryimport, author="Wolfram Research", title="{RawMemoryImport}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/RawMemoryImport.html}", note=[Accessed: 28-April-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_rawmemoryimport, organization={Wolfram Research}, title={RawMemoryImport}, year={2023}, url={https://reference.wolfram.com/language/ref/RawMemoryImport.html}, note=[Accessed: 28-April-2024 ]}