"String" (Compiled Type)
"String"
represents a string type specifier.
Details
- "String" can be used in Typed and related constructs to specify a type.
- "String" objects are automatically memory managed.
Properties
- The characters stored in a "String" type value are the same as those in a String expression.
Constructors
- CreateTypeInstance["String",cstr,len] creates a string from a C string cstr with length len. cstr can have type "CString" or "Managed"::["CString"].
- CreateTypeInstance["String",cstr] creates a string from a null-terminated C string cstr.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
"String" can be used as input and output from a CompiledCodeFunction:
In[1]:=1

✖
https://wolfram.com/xid/0byy5chkx9qix9udbd6zonm-ck3oom
Out[1]=1

In[2]:=2

✖
https://wolfram.com/xid/0byy5chkx9qix9udbd6zonm-o6ru94
Out[2]=2

Scope (1)Survey of the scope of standard use cases
Cast a string to a "Managed"::["CString"] and print its contents:
In[1]:=1

✖
https://wolfram.com/xid/0byy5chkx9qix9udbd6zonm-idcva5
Out[1]=1

In[2]:=2

✖
https://wolfram.com/xid/0byy5chkx9qix9udbd6zonm-4qyucg
Out[2]=2

In[3]:=3

✖
https://wolfram.com/xid/0byy5chkx9qix9udbd6zonm-qlp3jv
Out[3]=3

When a managed object is passed to a function from a library, the raw object is automatically unpacked.
When a managed object is no longer used, it frees its contents.
Possible Issues (1)Common pitfalls and unexpected behavior
A string can be cast to a "CString", but the result will need to be freed with a call to DeleteObject when it is no longer used:
In[4]:=4

✖
https://wolfram.com/xid/0byy5chkx9qix9udbd6zonm-t74ed5
Out[4]=4

In[5]:=5

✖
https://wolfram.com/xid/0byy5chkx9qix9udbd6zonm-bk0qva
Out[5]=5

In[6]:=6

✖
https://wolfram.com/xid/0byy5chkx9qix9udbd6zonm-lu878t
Out[6]=6
