WSGetUCS2String (C Function)

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

gets a character string from the WSTP connection specified by link, storing the string in s as a sequence of UCS-2 characters.

Details

  • WSGetUCS2String() allocates memory for the character string. You must call WSReleaseUCS2String() to disown this memory. If WSGetUCS2String() fails and the function's return value indicates an error, do not call WSReleaseUCS2String() on the contents of s.
  • WSGetUCS2String() returns immutable data.
  • WSGetUCS2String() stores all characters directly in 16-bit UCS-2 form.
  • ASCII characters are stored with a null high-order byte.
  • WSGetUCS2String() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSGetUCS2String() fails.
  • WSGetUCS2String() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

/* read a UCS-2 encoded string from a link */

void f(WSLINK lp)
{
    const unsigned short *string;
    int length;

    if(! WSGetUCS2String(lp, &string, &length))
        {
            /* unable to read the UCS-2 string */
            return;
        }

    /* ... */

    WSReleaseUCS2String(lp, string, length);
}