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.
40 lines
967 B
40 lines
967 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 include="string-non-null-zero-length.html" />
|
|
|
|
<div include="symbols-are-strings.html" />
|
|
|
|
example: |
|
|
const char *str;
|
|
|
|
str = duk_get_string(ctx, -3);
|
|
if (str) {
|
|
printf("value is a string: %s\n", str);
|
|
}
|
|
|
|
tags:
|
|
- stack
|
|
- string
|
|
|
|
seealso:
|
|
- duk_get_lstring
|
|
- duk_get_string_default
|
|
- duk_get_lstring_default
|
|
|
|
introduced: 1.0.0
|
|
|