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.
30 lines
732 B
30 lines
732 B
=proto
|
|
duk_size_t duk_get_length(duk_context *ctx, duk_idx_t index);
|
|
|
|
=stack
|
|
[ ... val! ... ]
|
|
|
|
=summary
|
|
<p>Get a type-specific "length" for value at <code>index</code>:</p>
|
|
<ul>
|
|
<li>String: character length of string (<i>not</i> byte length)</li>
|
|
<li>Object: <code>Math.floor(ToNumber(obj.length))</code> if result within
|
|
32-bit unsigned range; otherwise 0</li>
|
|
<li>Buffer: byte length of buffer</li>
|
|
<li>Other type or invalid stack index: 0</li>
|
|
</ul>
|
|
|
|
<p>To get the byte length of a string, use
|
|
<code><a href="#duk_get_lstring">duk_get_lstring()</a></code>.
|
|
</p>
|
|
|
|
=example
|
|
if (duk_is_string(ctx, -3)) {
|
|
printf("string char len is %lu\n", (unsigned long) duk_get_length(ctx, -3));
|
|
}
|
|
|
|
=tags
|
|
stack
|
|
|
|
=introduced
|
|
1.0.0
|
|
|