This feature is not supported on the Wolfram Cloud.
int WSGetByteString(WSLINK link,const unsigned char **s,int *n,long spec)
gets a string of characters from the WSTP connection specified by link, storing the codes for the characters in s and the number of characters in n. The code spec is used for any character whose Wolfram Language character code is larger than 255.
- WSGetByteString() allocates memory for the array of character codes. You must call WSReleaseByteString() to disown this memory. If WSGetByteString() fails and the function's return value indicates an error, do not call WSReleaseByteString() on the value contained in s.
- WSGetByteString() is convenient in situations where no special characters occur.
- The character codes used by WSGetByteString() are exactly the ones returned by ToCharacterCode in the Wolfram Language.
- The array of character codes in WSGetByteString() is not terminated by a null character.
- Characters such as newlines are specified by their raw character codes, not by ASCII forms such as ∖n.
- WSGetByteString() returns immutable data.
- WSGetByteString() returns 0 in the event of an error, and a nonzero value if the function succeeds.
- Use WSError() to retrieve the error code if WSGetByteString() fails.
- WSGetByteString() is declared in the WSTP header file wstp.h.
/* read a string encoded with codes from ToCharacterCode from a link */
void f(MLINK lp)
const unsigned char *string;
if(! WSGetByteString(lp, &string, &length, 0))
/* unable to read the byte string from lp */
/* ... */
WSReleaseByteString(lp, string, length);