Module Quickjs.String

JavaScript 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.

JavaScript vs OCaml Semantics

This library follows JavaScript semantics in most cases to ensure compatibility with the ECMA-262 specification:

type normalization =
  1. | NFC
  2. | NFD
  3. | NFKC
  4. | NFKD

Unicode normalization forms

val is_valid_utf8 : string -> bool

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 ... end

String.prototype methods

val lowercase_char : Uchar.t -> Uchar.t list

lowercase_char c converts a single character to lowercase. May return multiple characters for special cases.

val uppercase_char : Uchar.t -> Uchar.t list

uppercase_char c converts a single character to uppercase. May return multiple characters (e.g., ß -> SS).