WSPutByteString (C Function)

int WSPutByteString(WSLINK link,const unsigned char *s,int n)

puts a string of n characters starting from location s to the WSTP connection specified by link.


  • All characters in the string must be specified using character codes as obtained from ToCharacterCode in the Wolfram Language.
  • Newlines must thus be specified in terms of their raw character codes, rather than using n.
  • WSPutByteString() handles only characters with codes less than 256.
  • It can handle both ordinary ASCII as well as ISO Latin-1 characters.
  • WSPutByteString() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSPutByteString() fails.
  • WSPutByteString() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include "wstp.h"

/* transfer a string from a source link to a destination link */

void f(WSLINK sourcelink, WSLINK destinationlink)
    const unsigned char *string;
    int length;

    if(! WSGetByteString(sourcelink, &string, &length, 0))
        { /* unable to get the string from sourcelink */ }

    if(! WSPutByteString(destinationlink, string, length))
        { /* unable to put the string to destination link */ }