WSPutUTF8String (C 函数)

int WSPutUTF8String(WSLINK link,const unsigned char *s,int len)

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

更多信息

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

范例

基本范例  (1)

#include "wstp.h"

/* send an Integrate[] expression to a link */

void f(WSLINK lp)
{
    unsigned char *expr = "Integrate[1/Sin[x],x]";

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

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

    if(! WSPutUTF8String(lp, (const unsigned char *)expr, 21))
        { /* unable to send the expression to lp */ }

    if(! WSEndPacket(lp))
        { /* unable to send the end-of-packet indicator to lp */ }

    if(! WSFlush(lp))
        { /* unable to flush any buffered outgoing data to lp */ }
}