OpenersNotesSection(Spacer1)Details

MLGetUTF16String() allocates memory for the character string. You must call (NonWLLink[MLReleaseUTF16String(), paclet:ref/c/MLReleaseUTF16String]) to disown this memory. If MLGetUTF16String() fails and the function's return value indicates an error, do not call (NonWLLink[MLReleaseUTF16String(), paclet:ref/c/MLReleaseUTF16String]) on the contents of s.

MLGetUTF16String() returns immutable data.

MLGetUTF16String() stores all characters directly in the UTF-16 Unicode encoding form.

The string s returned by MLGetUTF16String() begins with a byte order mark.

The length of the string n includes the byte order mark.

MLGetUTF16String() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[MLError(), paclet:ref/c/MLError]) to retrieve the error code if MLGetUTF16String() fails.

MLGetUTF16String() is declared in the MathLink header file (RefLink[mathlink.h, paclet:ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

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

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

	if(! MLGetUTF16String(lp, &string, &length, &characters))
		{
			/* unable to read the UTF-16 string from lp */
			return;
		}

	/* ... */

	MLReleaseUTF16String(lp, string, length);
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLGetString(), paclet:ref/c/MLGetString])  ▪  (NonWLLink[MLGetByteString(), paclet:ref/c/MLGetByteString])  ▪  (NonWLLink[MLGetUCS2String(), paclet:ref/c/MLGetUCS2String])  ▪  (NonWLLink[MLGetUTF8String(), paclet:ref/c/MLGetUTF8String])  ▪  (NonWLLink[MLGetUTF32String(), paclet:ref/c/MLGetUTF32String])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(RefLinkPlain[Handling Lists, Arrays and Other Expressions, paclet:tutorial/HandlingListsArraysAndOtherExpressions])}})}})