mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
=proto
|
|
const char *duk_get_lstring(duk_context *ctx, int index, size_t *out_len);
|
|
|
|
=stack
|
|
[ ... val! ... ]
|
|
|
|
=summary
|
|
<p>Get character data pointer and length for a string at <code>index</code>
|
|
without modifying or coercing the value. Returns a non-<code>NULL</code>
|
|
pointer to the read-only, NUL-terminated string data, and writes the
|
|
string byte length to <code>*out_len</code> (if <code>out_len</code> is
|
|
non-<code>NULL</code>). Returns <code>NULL</code> and writes zero to <code>*out_len</code>
|
|
(if <code>out_len</code> is non-<code>NULL</code>) if the value is not a string or
|
|
the index is invalid.</p>
|
|
|
|
<p>To get the string character length (instead of byte length), use
|
|
<code><a href="#duk_get_length">duk_get_length()</a></code>.</p>
|
|
|
|
<div class="note">
|
|
A non-<code>NULL</code> return value is guaranteed even for zero length strings;
|
|
this differs from how buffer data pointers are handled (for technical reasons).
|
|
</div>
|
|
|
|
=example
|
|
const char *buf;
|
|
size_t len;
|
|
|
|
buf = duk_get_lstring(ctx, -3, &len);
|
|
if (buf) {
|
|
printf("value is a string, %d bytes\n", (int) len);
|
|
}
|
|
|
|
=tags
|
|
stack
|
|
|