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

int WSGetNumberAsUCS2String(WSLINK l, const unsigned short **s, int *n)
reads the next number on the WSTP connection specified by l as a string of UCS2 characters representing the number value stored in the string s of length n.

DetailsDetails

  • WSGetNumberAsUCS2String() allocates memory to store the string value. To release the memory allocated by WSGetNumberAsUCS2String(), call WSReleaseUCS2String() on the contents of s. If WSGetNumberAsUCS2String() fails, do not call WSReleaseUCS2String() on the contents of s.
  • WSGetNumberAsUCS2String() returns 0 on error and a nonzero value on success.
  • WSGetNumberAsUCS2String() is declared in the WSTP header file wstp.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"

/* A function for reading an integer from a link */

void f(MLINK l)
{
    switch(WSGetType(l))
    {
        case MLTKINT:
        {
            int rawType;
            rawType = WSGetRawType(l);
            if(rawType == MLTK_MLSHORT)
            {
                short theNumber;
                WSGetInteger16(l, &theNumber);
                /* ... */
            }
            else if(rawType == MLTK_MLINT)
            {
                int theNumber;
                WSGetInteger32(l, &theNumber);
                /* ... */
            }
            else
            {
                const unsigned short *theNumber;
                int length;
                WSGetNumberAsUCS2String(l, &theNumber, &length);
                /* ... */
                WSReleaseUCS2String(l, theNumber, length);
            }
        }
        break;
        case MLTKREAL:
            /* ... */
    }
}