WSTestUTF16String (C Function)

int WSTestUTF16String(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 UTF-16 encoded string of length n.


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


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[9];

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

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