MLGetUCS2String (C Function)

MLGetUCS2String has been replaced by WSGetUCS2String.

int MLGetUCS2String(MLINK link,const unsigned short **s,int *n)

gets a character string from the MathLink connection specified by link, storing the string in s as a sequence of UCS-2 characters.

Details

  • MLGetUCS2String() allocates memory for the character string. You must call MLReleaseUCS2String() to disown this memory. If MLGetUCS2String() fails and the function's return value indicates an error, do not call MLReleaseUCS2String() on the contents of s.
  • MLGetUCS2String() returns immutable data.
  • MLGetUCS2String() stores all characters directly in 16-bit UCS-2 form.
  • ASCII characters are stored with a null high-order byte.
  • MLGetUCS2String() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLGetUCS2String() fails.
  • MLGetUCS2String() is declared in the MathLink header file mathlink.h.

Examples

Basic Examples  (1)

#include "mathlink.h"

/* read a UCS-2 encoded string from a link */

void f(MLINK lp)
{
    const unsigned short *string;
    int length;

    if(! MLGetUCS2String(lp, &string, &length))
        {
            /* unable to read the UCS-2 string */
            return;
        }

    /* ... */

    MLReleaseUCS2String(lp, string, length);
}