WSUTF16ErrorMessage (C Function)

const unsigned short * WSUTF16ErrorMessage(WSLINK l, int *n)

returns a character string of length n encoded in the UTF-16 character encoding that represents the message describing the last error to occur on the WSTP connection specified by l.

Details

  • WSUTF16ErrorMessage() allocates memory for the message string that must be released. Use WSReleaseUTF16ErrorMessage() to release the memory allocated by WSUTF16ErrorMessage(). If WSUTF16ErrorMessage() returns NULL, do not call WSReleaseUTF16ErrorMessage() on the NULL value.
  • Programs should not modify the contents of the error message string.
  • WSUTF16ErrorMessage() returns a string that begins with a platform-appropriate byte order mark.
  • The length of the string n includes the byte order mark.
  • WSUTF16ErrorMessage() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

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

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

    message = WSUCS2ErrorMessage(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 */ }

    /* ... */

    WSReleaseUTF16ErrorMessage(l, message, length);
}