This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
MathLink C Function


int MLGetUnicodeString(MLINK link, unsigned short **s, long *n)
gets a character string from the MathLink connection specified by link, storing the string in s as a sequence of 16-bit Unicode characters.
  • MLGetUnicodeString() allocates memory for the character string. You must call MLDisownUnicodeString() to disown this memory. If MLGetUnicodeString() fails and the function's return value indicates and error, do not call MLDisownUnicodeString() on the contents of s.
  • MLGetUnicodeString() returns immutable data.
  • MLGetUnicodeString() stores all characters directly in 16-bit UCS-2 form.
  • ASCII characters are stored with a null high-order byte.
  • MLGetUnicodeString() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLGetUnicodeString() fails.
#include "mathlink.h"

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

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

    if(! MLGetUnicodeString(lp, &string, &length))
            /* unable to read the UCS-2 string */

    /* ... */

    MLDisownUnicodeString(lp, string, length);