OpenersNotesSection(Spacer1)Details

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

WSGetNumberAsUTF8String() returns 0 on error and a nonzero value if the function succeeds.

WSGetNumberAsUTF8String() 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 char *theNumber;
				int length, characters;
				WSGetNumberAsUTF8String(l, &theNumber, &length, &characters);
				/* ... */
				WSReleaseUTF8String(l, theNumber, length);
			}
		}
		break;
		case WSTKREAL:
			/* ... */
	}
}

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

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