MLGetUTF8Symbol (C Function)

MLGetUTF8Symbol has been replaced by WSGetUTF8Symbol.

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

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

Details

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

Examples

Basic Examples  (1)

#include "mathlink.h"

/* read an UTF-8 encoded symbol from a link */

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

    if(! MLGetUTF8Symbol(lp, &symbol, &bytes, &characters))
        {
            /* unable to read the UTF-8 symbol from lp */
            return;
        }

    /* ... */

    MLReleaseUTF8Symbol(lp, symbol, bytes);
}