WSGetUTF8Symbol()
This feature is not supported on the Wolfram Cloud.

int WSGetUTF8Symbol(WSLINK link,const unsigned char **s,int *b,int *c)
gets a UTF-8 encoded character string corresponding to the name of a symbol from the WSTP connection specified by link, storing the result in s, the number of bytes in the string in b, and the number of characters in the string in c.

DetailsDetails

  • WSGetUTF8Symbol() allocates memory for the character string. You must call WSReleaseUTF8Symbol() to disown this memory. If WSGetUTF8Symbol() fails and the function's return value indicates an error, do not call WSReleaseUTF8Symbol() on the contents of s.
  • WSGetUTF8Symbol() returns immutable data.
  • WSGetUTF8Symbol() stores all characters directly in the UTF-8 Unicode encoding form.
  • WSGetUTF8Symbol() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSGetUTF8Symbol() fails.
  • WSGetUTF8Symbol() is declared in the WSTP header file wstp.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"

/* read an UTF-8 encoded symbol from a link */

void f(MLINK lp)
{
    const unsigned char *symbol;
    int bytes;
    int characters;

    if(! WSGetUTF8Symbol(lp, &symbol, &bytes, &characters))
        {
            /* unable to read the UTF-8 symbol from lp */
            return;
        }

    /* ... */

    WSReleaseUTF8Symbol(lp, symbol, bytes);
}