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.
36 lines
978 B
36 lines
978 B
name: duk_get_string
|
|
|
|
proto: |
|
|
const char *duk_get_string(duk_context *ctx, duk_idx_t idx);
|
|
|
|
stack: |
|
|
[ ... val! ... ]
|
|
|
|
summary: |
|
|
<p>Get character data pointer for a string at <code>idx</code> without
|
|
modifying or coercing the value. Returns a non-<code>NULL</code> pointer to
|
|
the read-only, NUL-terminated string data. Returns <code>NULL</code> if the
|
|
value is not a string or the index is invalid.</p>
|
|
|
|
<p>To get the string byte length explicitly (which is useful if the string
|
|
contains embedded NUL characters), use
|
|
<code><a href="#duk_get_lstring">duk_get_lstring()</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;
|
|
|
|
buf = duk_get_string(ctx, -3);
|
|
if (buf) {
|
|
printf("value is a string: %s\n", buf);
|
|
}
|
|
|
|
tags:
|
|
- stack
|
|
- string
|
|
|
|
introduced: 1.0.0
|
|
|