MLTestUTF16String (C Function)

MLTestUTF16String has been replaced by WSTestUTF16String.

int MLTestUTF16String(MLINK 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.

Details

  • MLTestUTF16String() fails if the current object on the link is not a string, or if the value of the string does not match s.
  • MLTestUTF16String() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLTestUTF16String() fails.
  • MLTestUTF16String() will reset the stream pointer to the expression on the link just prior to calling MLTestUTF16String()if the function fails. This operation behaves as if the programmer called MLCreateMark(link); MLTestUTF16String(); MLSeekToMark().
  • 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.
  • MLTestUTF16String() is declared in the MathLink header file mathlink.h.

Examples

Basic Examples  (1)

#include "mathlink.h"

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

void f(MLINK 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(! MLTestUTF16String(l, (const unsigned short *)theString,
        9))
    { /* The next expression on the link is not $Version */ }
    else
    { /* The next expression on the link is $Version */ }
}