JS_GetLatin1StringCharsAndLength

There was a scripting error on this page. While it is being addressed by site editors, you can view partial content below.

{{SpiderMonkeySidebar("JSAPI")}}

{{ jsapi_minversion_header("38") }}

Get the chars and the length of a string.

Syntax

const JS::Latin1Char *
JS_GetLatin1StringCharsAndLength(JSContext *cx, const JS::AutoCheckCannotGC &nogc,
                                 JSString *str, size_t *length);

const char16_t *
JS_GetTwoByteStringCharsAndLength(JSContext *cx, const JS::AutoCheckCannotGC &nogc,
                                  JSString *str, size_t *length);
Name Type Description
cx {{jsapixref("JSRuntime", "JSContext *")}} A context. {{ Jsapi-requires-request() }}.
nogc {{jsapixref("JS::AutoCheckCannotGC", "JS::AutoCheckCannotGC &")}} A reference to {{jsapixref("JS::AutoCheckCannotGC")}}.
str {{jsapixref("JSString", "JSString *")}} A string to get characters.
length size_t * Out parameter. Receives the length of the string.

Description

JS_GetLatin1StringCharsAndLength and JS_GetTwoByteStringCharsAndLength get the characters and the length of the string, str.

If successful, JS_GetLatin1StringCharsAndLength and JS_GetTwoByteStringCharsAndLength return a pointer to the string, and store the length to *length, otherwise return NULL.

See Also

  • {{ LXRSearch("ident", "i", "JS_GetLatin1StringCharsAndLength") }}
  • {{ LXRSearch("ident", "i", "JS_GetTwoByteStringCharsAndLength") }}
  • {{jsapixref("JS_GetLatin1FlatStringChars")}}
  • {{jsapixref("JS_GetLatin1FlatStringChars", "JS_GetTwoByteFlatStringChars")}}
  • {{jsapixref("JS_GetLatin1InternedStringChars")}}
  • {{jsapixref("JS_GetLatin1InternedStringChars", "JS_GetTwoByteInternedStringChars")}}
  • {{bug(1032726)}}

Document Tags and Contributors

Contributors to this page: kscarfone, arai
Last updated by: kscarfone,