WSPutUTF16String (C Function)

int WSPutUTF16String(WSLINK link,const unsigned short *s,int len)

puts a UTF-16 string s of length len to the WSTP connection specified by link.

Details

  • WSPutUTF16String() determines the number of characters in the string s automatically.
  • The string s encoded in the UTF-16 encoding form must start with a byte order mark.
  • The string length len must include the byte order mark.
  • WSPutUTF16String() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSPutUTF16String() fails.
  • WSPutUTF16String() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

/* send the expression N[10/Sin[2]] to a link */

void f(WSLINK lp)
{
    unsigned short expr[13];

    expr[0] = 0xFEFF;
    expr[1] = 'N';
    expr[2] = '[';
    expr[3] = '1';
    expr[4] = '0';
    expr[5] = '/';
    expr[6] = 'S';
    expr[7] = 'i';
    expr[8] = 'n';
    expr[9] = '[';
    expr[10] = '2';
    expr[11] = ']';
    expr[12] = ']';

    if(! WSPutFunction(lp, "EvaluatePacket", 1))
        { /* unable to put the function to lp */ }

    if(! WSPutFunction(lp, "ToExpression", 1))
        { /* unable to put the function to lp */ }

    if(! WSPutUTF16String(lp, (const unsigned short *)expr, 13))
        { /* unable to put the expression string to lp */ }

    if(! WSEndPacket(lp))
        { /* unable to put the end-of-packet indicator to lp */ }
    
    if(! WSFlush(lp))
        { /* unable to flush any outgoing data buffered in lp */ }
}