RawMemoryExport
Details and Options


- RawMemoryExport returns a managed RawPointer object.
- type can be omitted if expr is a string, ByteArray or NumericArray.
- Possible element types and their corresponding C types include:
-
"UnsignedInteger8" uint8_t unsigned 8-bit integer "Integer8" int8_t signed 8-bit integer "UnsignedInteger16" uint16_t unsigned 16-bit integer "Integer16" int16_t signed 16-bit integer "UnsignedInteger32" uint32_t unsigned 32-bit integer "Integer32" int32_t signed 32-bit integer "UnsignedInteger64" uint64_t unsigned 64-bit integer "Integer64" int64_t signed 64-bit integer "CUnsignedChar" unsigned char C-compatible unsigned char "CSignedChar" signed char C-compatible signed char "CUnsignedShort" unsigned short C-compatible unsigned short "CShort" short C-compatible short "CUnsignedInt" unsigned int C-compatible unsigned int "CInt" int C-compatible int "CUnsignedLong" unsigned long C-compatible unsigned long "CLong" long C-compatible long "CSizeT" size_t C-compatible size_t "CFloat" float C-compatible float "CDouble" double C-compatible double "OpaqueRawPointer" void* opaque pointer "RawPointer"::[t] t* typed pointer {ty1,ty2,…} struct {ty1 f1; ty2 f2; …} struct or product type "Void" void no output (only in output types) - If expr is a ByteArray or a NumericArray, only integral and real types are allowed as the element type.
- The following options are supported:
-
CharacterEncoding "UTF-8" character encoding
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Export a raw memory representation of an integer:

https://wolfram.com/xid/0dqwiufp086-p4s54e

Read the contents of the pointer:

https://wolfram.com/xid/0dqwiufp086-779qjo

Export a raw memory representation of a string:

https://wolfram.com/xid/0dqwiufp086-uv72gz

Import the contents of the raw memory:

https://wolfram.com/xid/0dqwiufp086-e7lfgh

Scope (3)Survey of the scope of standard use cases
Use the second argument of RawMemoryExport to specify the element type of the exported raw memory:

https://wolfram.com/xid/0dqwiufp086-zvs2o7


https://wolfram.com/xid/0dqwiufp086-s8hw68

The element type can be omitted if the exported expression is a string, a ByteArray or a NumericArray:

https://wolfram.com/xid/0dqwiufp086-lmysyz


https://wolfram.com/xid/0dqwiufp086-cf4cg6


https://wolfram.com/xid/0dqwiufp086-snhjcr

The raw memory is null-terminated when a string is exported:

https://wolfram.com/xid/0dqwiufp086-2dvnn

Options (1)Common values & functionality for each option
CharacterEncoding (1)
Specify what CharacterEncoding should be used when exporting a string:

https://wolfram.com/xid/0dqwiufp086-2htoma
Compare the contents of the pointers:

https://wolfram.com/xid/0dqwiufp086-zh75gj


https://wolfram.com/xid/0dqwiufp086-gvdilv

Properties & Relations (3)Properties of the function, and connections to other functions
By default, RawMemoryExport returns a RawPointer wrapped in ManagedObject:

https://wolfram.com/xid/0dqwiufp086-pnx687

Use UnmanageObject to unmanage the pointer:

https://wolfram.com/xid/0dqwiufp086-4zay7p

RawMemoryImport is the inverse operation of RawMemoryExport:

https://wolfram.com/xid/0dqwiufp086-x10wkb


https://wolfram.com/xid/0dqwiufp086-i3r68f

Use ForeignFunctionLoad to load a function that computes the sum of the elements of a raw memory:

https://wolfram.com/xid/0dqwiufp086-ngv0o5

Export a list as a raw memory of "CLong" objects:

https://wolfram.com/xid/0dqwiufp086-g1rwc0

Call the function by passing the buffer and its length:

https://wolfram.com/xid/0dqwiufp086-2in6km

Possible Issues (5)Common pitfalls and unexpected behavior
Strings can only be exported as a raw memory of "UnsignedInteger8" objects:

https://wolfram.com/xid/0dqwiufp086-2cxujy

The element type of the raw memory cannot be automatically determined if the inputted expression is a list:

https://wolfram.com/xid/0dqwiufp086-68pajx


Specify the target element type:

https://wolfram.com/xid/0dqwiufp086-0rkglw

RawMemoryExport will return $Failed if the element type is not supported:

https://wolfram.com/xid/0dqwiufp086-0o9mhd


RawMemoryExport will return $Failed if an element does not match the specified element type:

https://wolfram.com/xid/0dqwiufp086-3zrzfe


If the exported expression is a ByteArray or a NumericArray, the element type can only be integral and real types:

https://wolfram.com/xid/0dqwiufp086-ru60x1


Wolfram Research (2023), RawMemoryExport, Wolfram Language function, https://reference.wolfram.com/language/ref/RawMemoryExport.html.
Text
Wolfram Research (2023), RawMemoryExport, Wolfram Language function, https://reference.wolfram.com/language/ref/RawMemoryExport.html.
Wolfram Research (2023), RawMemoryExport, Wolfram Language function, https://reference.wolfram.com/language/ref/RawMemoryExport.html.
CMS
Wolfram Language. 2023. "RawMemoryExport." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RawMemoryExport.html.
Wolfram Language. 2023. "RawMemoryExport." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RawMemoryExport.html.
APA
Wolfram Language. (2023). RawMemoryExport. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RawMemoryExport.html
Wolfram Language. (2023). RawMemoryExport. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RawMemoryExport.html
BibTeX
@misc{reference.wolfram_2025_rawmemoryexport, author="Wolfram Research", title="{RawMemoryExport}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/RawMemoryExport.html}", note=[Accessed: 19-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_rawmemoryexport, organization={Wolfram Research}, title={RawMemoryExport}, year={2023}, url={https://reference.wolfram.com/language/ref/RawMemoryExport.html}, note=[Accessed: 19-June-2025
]}