OpenersNotesSection(Spacer1)Details

MLUTF16ErrorMessage() allocates memory for the message string that must be released. Use (NonWLLink[MLReleaseUTF16ErrorMessage(), paclet:/ref/c/MLReleaseUTF16ErrorMessage]) to release the memory allocated by MLUTF16ErrorMessage(). If MLUTF16ErrorMessage() returns NULL, do not call (NonWLLink[MLReleaseUTF16ErrorMessage(), paclet:/ref/c/MLReleaseUTF16ErrorMessage]) on the NULL value.

Programs should not modify the contents of the error message string.

MLUTF16ErrorMessage() returns a string that begins with a platform-appropriate byte order mark.

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

MLUTF16ErrorMessage() 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"

/* A function for reading the error message from a link */

void f(MLINK l)
{
	const unsigned short *message;
	int length;

	message = MLUCS2ErrorMessage(l, &length);

	/* We check for length <= 1 below because the string
	should contain a byte order mark */
	if(message == (const unsigned short *)0 || length <= 1)
	{ /* Unable to read the error message */ }

	/* ... */

	MLReleaseUTF16ErrorMessage(l, message, length);
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLReleaseUTF16ErrorMessage(), paclet:/ref/c/MLReleaseUTF16ErrorMessage])  ▪  (NonWLLink[MLErrorMessage(), paclet:/ref/c/MLErrorMessage])  ▪  (NonWLLink[MLUCS2ErrorMessage(), paclet:/ref/c/MLUCS2ErrorMessage])  ▪  (NonWLLink[MLUTF32ErrorMessage(), paclet:/ref/c/MLUTF32ErrorMessage])  ▪  (NonWLLink[MLUTF8ErrorMessage(), paclet:/ref/c/MLUTF8ErrorMessage])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Error and Interrupt Handling, paclet:tutorial/ErrorAndInterruptHandling])}})}})