malloc-string ( string encoding -- alien )
Factor handbook » C library interface » Passing data between Factor and C » C strings

Prev:string>alien ( string encoding -- byte-array )
Next:alien>string ( c-ptr encoding -- string/f )


Vocabulary
alien.data

Inputs
stringa string
encodingan encoding descriptor


Outputs
aliena c-ptr


Word description
Encodes a string together with a trailing null code point using the given encoding, and stores the resulting bytes in a freshly-allocated unmanaged memory block.

Warning
Don't forget to deallocate the memory with a call to free.


Errors
Throws an error if one of the following conditions occurs:
the string contains null code points
the string contains characters not representable using the encoding specified
memory allocation fails


See also
string>alien, alien>string

Definition