OpenersNotesSection(Spacer1)Details

All characters in the string must be specified using character codes as obtained from (RefLink[ToCharacterCode, paclet:ref/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 (NonWLLink[WSError(), paclet:ref/c/WSError]) to retrieve the error code if WSPutByteString() fails.

WSPutByteString() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)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 */ }
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSPutString(), paclet:ref/c/WSPutString])  ▪  (NonWLLink[WSPutUCS2String(), paclet:ref/c/WSPutUCS2String])  ▪  (NonWLLink[WSPutUTF8String(), paclet:ref/c/WSPutUTF8String])  ▪  (NonWLLink[WSPutUTF16String(), paclet:ref/c/WSPutUTF16String])  ▪  (NonWLLink[WSPutUTF32String(), paclet:ref/c/WSPutUTF32String])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(RefLinkPlain[Handling Lists, Arrays and Other Expressions, paclet:tutorial/HandlingListsArraysAndOtherExpressions])}, {▪(RefLinkPlain[Portability of WSTP Programs, paclet:tutorial/PortabilityOfWSTPPrograms])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Strings, paclet:guide/WSTPCFunctionsForExchangingStrings])}})}})