WSPutUTF16String (C 函数)

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

把长度为 len 的 UTF-16 字符串 s 写入由 link 指定的 WSTP 连接.

更多信息

  • WSPutUTF16String() 自动决定字符串 s 中的字符数.
  • 若发生错误,则 WSPutUTF16String() 返回0;若函数成功,则返回非零值.
  • WSPutUTF16String() 失败,则使用 WSError() 检索错误代码.
  • WSTP 的标头文件 wstp.h 已对 WSPutUTF16String() 作出声明.

范例

基本范例  (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 */ }
}