MLGetNumberAsUTF16String (C Function)

MLGetNumberAsUTF16String has been replaced by WSGetNumberAsUTF16String.

int MLGetNumberAsUTF16String(MLINK l, const unsigned short **s, int *v, int *c)

reads the next number of the MathLink connection specified by l as a string of UTF-16 characters representing the number value stored in the string s of length v and characters c.

Details

  • MLGetNumberAsUTF16String() allocates memory to store the string value. To release the memory allocated by MLGetNumberAsUTF16String(), call MLReleaseUTF16String() on the contents of s. If MLGetNumberAsUTF16String() fails, do not call MLReleaseUTF16String() on the contents of s.
  • The UTF-16 string s returned by MLGetNumberAsUTF16String() begins with a byte order mark.
  • The length of the string v includes the byte order mark.
  • MLGetNumberAsUTF16String() returns 0 on error and a nonzero value on success.
  • MLGetNumberAsUTF16String() is declared in the MathLink header file mathlink.h.

Examples

Basic Examples  (1)

#include "mathlink.h"

/* A function for reading an integer from a link */

void f(MLINK l)
{
    switch(MLGetType(l))
    {
        case MLTKINT:
        {
            int rawType;
            rawType = MLGetRawType(l);
            if(rawType == MLTK_MLSHORT)
            {
                short theNumber;
                MLGetInteger16(l, &theNumber);
                /* ... */
            }
            else if(rawType == MLTK_MLINT)
            {
                int theNumber;
                MLGetInteger32(l, &theNumber);
                /* ... */
            }
            else
            {
                const unsigned short *theNumber;
                int length, characters;
                MLGetNumberAsUTF16String(l, &theNumber, &length, &characters);
                /* ... */
                MLReleaseUTF16String(l, theNumber, length);
            }
        }
        break;
        case MLTKREAL:
            /* ... */
    }
}