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.

MLPutByteString() handles only characters with codes less than 256.

It can handle both ordinary ASCII as well as ISO Latin-1 characters.

MLPutByteString() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[MLError(), paclet:ref/c/MLError]) to retrieve the error code if MLPutByteString() fails.

MLPutByteString() is declared in the MathLink header file (RefLink[mathlink.h, paclet:ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

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

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

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

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

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLPutString(), paclet:ref/c/MLPutString])  ▪  (NonWLLink[MLPutUCS2String(), paclet:ref/c/MLPutUCS2String])  ▪  (NonWLLink[MLPutUTF8String(), paclet:ref/c/MLPutUTF8String])  ▪  (NonWLLink[MLPutUTF16String(), paclet:ref/c/MLPutUTF16String])  ▪  (NonWLLink[MLPutUTF32String(), paclet:ref/c/MLPutUTF32String])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(RefLinkPlain[Handling Lists, Arrays and Other Expressions, paclet:tutorial/HandlingListsArraysAndOtherExpressions])}})}})