name: duk_to_lstring proto: | const char *duk_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len); stack: | [ ... val! ... ] -> [ ... ToString(val)! ... ] summary: |

Replace the value at index with an Ecmascript ToString() coerced value. Returns a non-NULL pointer to the read-only, NUL-terminated string data, and writes the string byte length to *out_len (if out_len is non-NULL). If index is invalid, throws an error.

example: | const char *ptr; duk_size_t sz; ptr = duk_to_lstring(ctx, -3, &sz); printf("coerced string: %s (length %lu)\n", ptr, (unsigned long) sz); tags: - stack - string seealso: - duk_safe_to_lstring introduced: 1.0.0