OpenersNotesSection(Spacer1)Details

WSGetUnicodeString() allocates memory for the character string. You must call WSDisownUnicodeString() to disown this memory. If WSGetUnicodeString() fails and the function's return value indicates and error, do not call WSDisownUnicodeString() on the contents of s.

WSGetUnicodeString() returns immutable data.

WSGetUnicodeString() stores all characters directly in 16-bit UCS-2 form.

ASCII characters are stored with a null high-order byte.

WSGetUnicodeString() 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 WSGetUnicodeString() fails.

WSGetUnicodeString() is equivalent to (NonWLLink[WSGetUCS2String(), paclet:ref/c/WSGetUCS2String]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "wstp.h"

/* read a UCS-2 encoded string from a link */

void f(WSLINK lp)
{
	const unsigned short *string;
	long length;

	if(! WSGetUnicodeString(lp, &string, &length))
		{
			/* unable to read the UCS-2 string */
			return;
		}

	/* ... */

	WSDisownUnicodeString(lp, string, length);
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSGetString(), paclet:ref/c/WSGetString])  ▪  (NonWLLink[WSGetByteString(), paclet:ref/c/WSGetByteString])}})}})

({{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])}})}})