name: duk_substring proto: | void duk_substring(duk_context *ctx, duk_idx_t idx, duk_size_t start_char_offset, duk_size_t end_char_offset); stack: | [ ... str! ... ] -> [ ... substr! ... ] summary: |
Replace a string at idx
with a substring [start_char_offset
,
end_char_offset
[ of the string itself. If the value at idx
is
not a string or the index is invalid, throws an error.
The substring operation works with characters, not bytes, and the offsets
are character offsets. The semantics of this call are similar to
String.prototype.substring (start, end).
Offset values are clamped to string length (there is no need to clamp negative
values because size_t
is unsigned) and if start offset is larger than
end offset, the result is an empty string.
duk_get_lstring()
to get a string data
pointer and length, and
duk_push_lstring()
to push a slice of
bytes.