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.
 
 
 
 
 
 

32 lines
859 B

=proto
const char *duk_get_string(duk_context *ctx, int index);
=stack
[ ... val! ... ]
=summary
<p>Get character data pointer for a string at <tt>index</tt> without
modifying or coercing the value. Returns a non-<tt>NULL</tt> pointer to
the read-only, NUL-terminated string data. Returns <tt>NULL</tt> 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
<tt><a href="#duk_get_lstring">duk_get_lstring()</a></tt>.</p>
<div class="note">
A non-<tt>NULL</tt> 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);
if (buf) {
printf("value is a string: %s\n", buf);
}
=tags
stack
string