WSGetUTF16Symbol (C Function)

int WSGetUTF16Symbol(WSLINK link,const unsigned short **s,int *n,int *c)

gets a UTF-16 character string corresponding to the name of a symbol from the WSTP connection specified by link, storing the string in s, the length in n, and the number of characters in c.


  • WSGetUTF16Symbol() allocates memory for the character string. You must call WSReleaseUTF16Symbol() to disown this memory. If WSGetUTF16Symbol() fails and the function's return value indicates an error, do not call WSReleaseUTF16Symbol() on the contents of s.
  • WSGetUTF16Symbol() returns immutable data.
  • WSGetUTF16Symbol() stores all characters directly in the UTF-16 Unicode encoding form.
  • The symbol s returned by WSGetUTF16Symbol() begins with a byte order mark.
  • The length of the symbol n includes the byte order mark.
  • WSGetUTF16Symbol() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSGetUTF16Symbol() fails.
  • WSGetUTF16Symbol() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include "wstp.h"

/* read a UTF-16 symbol from a link */

void f(WSLINK lp)
    const unsigned short *symbol;
    int length;
    int characters;

    if(! WSGetUTF16Symbol(lp, &symbol, &length, &characters))
            /* unable to read the UTF-16 symbol from lp */

    /* ... */

    WSReleaseUTF16Symbol(lp, symbol, length, characters);