MLTestUTF8String (C Function)

MLTestUTF8String has been replaced by WSTestUTF8String.

int MLTestUTF8String(MLINK l, const unsigned char *s, int n)

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

Details

  • MLTestUTF8String() fails if the current object on the link is not a string, or if the value of the string does not match s.
  • MLTestUTF8String() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLTestUTF8String() fails.
  • MLTestUTF8String() will reset the stream pointer to the expression on the link just prior to calling MLTestUTF8String()if the function fails. This operation behaves as if the programmer called MLCreateMark(link); MLTestUTF8String(); MLSeekToMark().
  • MLTestUTF8String() 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 char 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(! MLTestUTF8String(l, (const unsigned char *)theString,
        8))
    { /* The next expression on the link is not $Version */ }
    else
    { /* The next expression on the link is $Version */ }
}