MLGetUTF8String has been replaced by WSGetUTF8String.

int MLGetUTF8String(MLINK link,const unsigned char **s,int *b,int *c)

gets a UTF-8 character string from the MathLink connection specified by link, storing the string in s, the number of bytes in the string in b, and the number of characters in the string in c.


  • MLGetUTF8String() allocates memory for the character string. You must call MLReleaseUTF8String() to disown this memory. If MLGetUTF8String() fails and the function's return value indicates an error, do not call MLReleaseUTF8String() on the contents of s.
  • MLGetUTF8String() returns immutable data.
  • MLGetUTF8String() stores all characters directly in the UTF-8 Unicode encoding form.
  • MLGetUTF8String() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLGetUTF8String() fails.
  • MLGetUTF8String() is declared in the MathLink header file mathlink.h.


Basic Examples  (1)

#include "mathlink.h"

/* read a UTF-8 encoded string from a link */

void f(MLINK lp)
    const unsigned char *string;
    int bytes;
    int characters;

    if(! MLGetUTF8String(lp, &string, &bytes, &characters))
            /* unable to read the UTF-8 string from lp */

    /* use the string */

    MLReleaseUTF8String(lp, string, bytes);

See Also

MLGetString()  MLGetByteString()  MLGetUCS2String()  MLGetUTF16String()  MLGetUTF32String()