Quickjs.StringJavaScript String built-in object
This module mirrors the JavaScript String API with prototype methods for string manipulation. All methods use UTF-16 semantics for indices.
This library follows JavaScript semantics in most cases to ensure compatibility with the ECMA-262 specification:
index_of return -1 when not found (JavaScript convention), not option (OCaml convention). This matches JavaScript's String.prototype.indexOf().char_code_at return int option (OCaml convention) for bounds checking, since OCaml does not have JavaScript's implicit NaN coercion.slice support negative indices counting from the end, matching JavaScript behavior.is_valid_utf8 s returns true if s contains only valid UTF-8 byte sequences. Use this for strict validation before processing untrusted input.
Note: All functions in this module handle invalid UTF-8 gracefully by replacing malformed sequences with U+FFFD (replacement character).
module Prototype : sig ... endString.prototype methods
lowercase_char c converts a single character to lowercase. May return multiple characters for special cases.