WSTestUCS2String (C Function)

int WSTestUCS2String(WSLINK l, const unsigned short *s, int n)

tests that the next expression to be read from l is a string with the value s, a UCS2 encoded string of length n.

Details

  • WSTestUCS2String() fails if the current object on the link is not a string, or if the value of the string does not match s.
  • WSTestUCS2String() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSTestUCS2String() fails.
  • WSTestUCS2String() will reset the stream pointer to the expression on the link just prior to calling WSTestUCS2String()if the function fails. This operation behaves as if the programmer called WSCreateMark(link); WSTestUCS2String(); WSSeekToMark().
  • WSTestUCS2String() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

/* A function for testing the next expression on the link for a string */

void f(WSLINK l)
{
    const unsigned short theString[8];

    theString[0] = '$'
    theString[1] = 'V';
    theString[2] = 'e';
    theString[3] = 'r';
    theString[4] = 's';
    theString[5] = 'i';
    theString[6] = 'o';
    theString[7] = 'n';

    if(! WSTestUCS2String(l, (const unsigned short *)theString,
        8))
    { /* The next expression on the link is not $Version */ }
    else
    { /* The next expression on the link is $Version */ }
}