OpenersNotesSection(Spacer1)Details

WSGetNumberAsUTF16String() allocates memory to store the string value. To release the memory allocated by WSGetNumberAsUTF16String(), call (NonWLLink[WSReleaseUTF16String(), paclet:ref/c/WSReleaseUTF16String]) on the contents of s. If WSGetNumberAsUTF16String() fails, do not call (NonWLLink[WSReleaseUTF16String(), paclet:ref/c/WSReleaseUTF16String]) on the contents of s.

The UTF-16 string s returned by WSGetNumberAsUTF16String() begins with a byte order mark.

The length of the string v includes the byte order mark.

WSGetNumberAsUTF16String() returns 0 on error and a nonzero value on success.

WSGetNumberAsUTF16String() 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"

/* A function for reading an integer from a link */

void f(WSLINK l)
{
	switch(WSGetType(l))
	{
		case WSTKINT:
		{
			int rawType;
			rawType = WSGetRawType(l);
			if(rawType == WSTK_WSSHORT)
			{
				short theNumber;
				WSGetInteger16(l, &theNumber);
				/* ... */
			}
			else if(rawType == WSTK_WSINT)
			{
				int theNumber;
				WSGetInteger32(l, &theNumber);
				/* ... */
			}
			else
			{
				const unsigned short *theNumber;
				int length, characters;
				WSGetNumberAsUTF16String(l, &theNumber, &length, &characters);
				/* ... */
				WSReleaseUTF16String(l, theNumber, length);
			}
		}
		break;
		case WSTKREAL:
			/* ... */
	}
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSReleaseUTF16String(), paclet:ref/c/WSReleaseUTF16String])  ▪  (NonWLLink[WSGetNumberAsString(), paclet:ref/c/WSGetNumberAsString])  ▪  (NonWLLink[WSGetNumberAsUCS2String(), paclet:ref/c/WSGetNumberAsUCS2String])  ▪  (NonWLLink[WSGetNumberAsUTF32String(), paclet:ref/c/WSGetNumberAsUTF32String])  ▪  (NonWLLink[WSGetNumberAsUTF8String(), paclet:ref/c/WSGetNumberAsUTF8String])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(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])}})}})