docs
Loading...
Searching...
No Matches
JSStringRef.h

Functions

JSStringRef JSStringCreateWithCharacters (const JSChar *chars, size_t numChars)
 Creates a JavaScript string from a buffer of Unicode characters.
JSStringRef JSStringCreateWithUTF8CString (const char *string)
 Creates a JavaScript string from a null-terminated UTF8 string.
JSStringRef JSStringRetain (JSStringRef string)
 Retains a JavaScript string.
void JSStringRelease (JSStringRef string)
 Releases a JavaScript string.
size_t JSStringGetLength (JSStringRef string)
 Returns the number of Unicode characters in a JavaScript string.
const JSChar * JSStringGetCharactersPtr (JSStringRef string)
 Returns a pointer to the Unicode character buffer that serves as the backing store for a JavaScript string.
size_t JSStringGetMaximumUTF8CStringSize (JSStringRef string)
 Returns the maximum number of bytes a JavaScript string will take up if converted into a null-terminated UTF8 string.
size_t JSStringGetUTF8CString (JSStringRef string, char *buffer, size_t bufferSize)
 Converts a JavaScript string into a null-terminated UTF8 string, and copies the result into an external byte buffer.
bool JSStringIsEqual (JSStringRef a, JSStringRef b)
 Tests whether two JavaScript strings match.
bool JSStringIsEqualToUTF8CString (JSStringRef a, const char *b)
 Tests whether a JavaScript string matches a null-terminated UTF8 string.

Typedefs

typedef unsigned short JSChar
 A UTF-16 code unit. One, or a sequence of two, can encode any Unicode character. As with all scalar types, endianness depends on the underlying architecture.

Function Documentation

◆ JSStringCreateWithCharacters()

JSStringRef JSStringCreateWithCharacters ( const JSChar * chars,
size_t numChars )

Creates a JavaScript string from a buffer of Unicode characters.

Parameters
charsThe buffer of Unicode characters to copy into the new JSString.
numCharsThe number of characters to copy from the buffer pointed to by chars.
Returns
A JSString containing chars. Ownership follows the Create Rule.

◆ JSStringCreateWithUTF8CString()

JSStringRef JSStringCreateWithUTF8CString ( const char * string)

Creates a JavaScript string from a null-terminated UTF8 string.

Parameters
stringThe null-terminated UTF8 string to copy into the new JSString.
Returns
A JSString containing string. Ownership follows the Create Rule.

◆ JSStringGetCharactersPtr()

const JSChar * JSStringGetCharactersPtr ( JSStringRef string)

Returns a pointer to the Unicode character buffer that serves as the backing store for a JavaScript string.

Parameters
stringThe JSString whose backing store you want to access.
Returns
A pointer to the Unicode character buffer that serves as string's backing store, which will be deallocated when string is deallocated.

◆ JSStringGetLength()

size_t JSStringGetLength ( JSStringRef string)

Returns the number of Unicode characters in a JavaScript string.

Parameters
stringThe JSString whose length (in Unicode characters) you want to know.
Returns
The number of Unicode characters stored in string.

◆ JSStringGetMaximumUTF8CStringSize()

size_t JSStringGetMaximumUTF8CStringSize ( JSStringRef string)

Returns the maximum number of bytes a JavaScript string will take up if converted into a null-terminated UTF8 string.

Parameters
stringThe JSString whose maximum converted size (in bytes) you want to know.
Returns
The maximum number of bytes that could be required to convert string into a null-terminated UTF8 string. The number of bytes that the conversion actually ends up requiring could be less than this, but never more.

◆ JSStringGetUTF8CString()

size_t JSStringGetUTF8CString ( JSStringRef string,
char * buffer,
size_t bufferSize )

Converts a JavaScript string into a null-terminated UTF8 string, and copies the result into an external byte buffer.

Parameters
stringThe source JSString.
bufferThe destination byte buffer into which to copy a null-terminated UTF8 representation of string. On return, buffer contains a UTF8 string representation of string. If bufferSize is too small, buffer will contain only partial results. If buffer is not at least bufferSize bytes in size, behavior is undefined.
bufferSizeThe size of the external buffer in bytes.
Returns
The number of bytes written into buffer (including the null-terminator byte).

◆ JSStringIsEqual()

bool JSStringIsEqual ( JSStringRef a,
JSStringRef b )

Tests whether two JavaScript strings match.

Parameters
aThe first JSString to test.
bThe second JSString to test.
Returns
true if the two strings match, otherwise false.

◆ JSStringIsEqualToUTF8CString()

bool JSStringIsEqualToUTF8CString ( JSStringRef a,
const char * b )

Tests whether a JavaScript string matches a null-terminated UTF8 string.

Parameters
aThe JSString to test.
bThe null-terminated UTF8 string to test.
Returns
true if the two strings match, otherwise false.

◆ JSStringRelease()

void JSStringRelease ( JSStringRef string)

Releases a JavaScript string.

Parameters
stringThe JSString to release.

◆ JSStringRetain()

JSStringRef JSStringRetain ( JSStringRef string)

Retains a JavaScript string.

Parameters
stringThe JSString to retain.
Returns
A JSString that is the same as string.

Typedef Documentation

◆ JSChar

typedef unsigned short JSChar

A UTF-16 code unit. One, or a sequence of two, can encode any Unicode character. As with all scalar types, endianness depends on the underlying architecture.

Go to the source code of this file.