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.
 
 
 
 
 
 

31 lines
909 B

=proto
const char *duk_to_lstring(duk_context *ctx, int index, size_t *out_len);
=stack
[ ... val! ... ] -> [ ... ToString(val)! ... ]
=summary
<p>Replace the value at <code>index</code> with an Ecmascript
<a href="http://www.ecma-international.org/ecma-262/5.1/#sec-9.8">ToString()</a>
coerced 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>). If <code>index</code> is invalid, throws
an error.</p>
<p>Custom type coercion:</p>
<ul>
<li>Buffer: coerces byte-for-byte into a string</li>
<li>Pointer: coerces to a string formatted with <code>sprintf()</code> format
<code>%p</code></li>
</ul>
=example
const char *ptr;
size_t sz;
ptr = duk_to_lstring(ctx, -3, &sz);
printf("coerced string: %s (length %d)\n", ptr, (int) sz);
=tags
stack
string