OpenersNotesSection(Spacer1)Details

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

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

WSGetNumberAsUCS2String() 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;
				WSGetNumberAsUCS2String(l, &theNumber, &length);
				/* ... */
				WSReleaseUCS2String(l, theNumber, length);
			}
		}
		break;
		case WSTKREAL:
			/* ... */
	}
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSReleaseUCS2String(), paclet:ref/c/WSReleaseUCS2String])  ▪  (NonWLLink[WSGetNumberAsString(), paclet:ref/c/WSGetNumberAsString])  ▪  (NonWLLink[WSGetNumberAsUTF16String(), paclet:ref/c/WSGetNumberAsUTF16String])  ▪  (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])}})}})