Skip to content

StdLib String

Roger Johansson edited this page Jan 14, 2026 · 1 revision

String

The String built-in provides methods for creating and manipulating text.

Implementation Status: 100% Complete

Overview

Category Methods Implemented
Static Methods 4 4
Character Access 4 4
Search Methods 6 6
Substring Methods 3 3
Transformation Methods 12 12
Pattern Matching 5 5
Unicode Methods 3 3
HTML Wrappers (Annex B) 13 13
Total 50 50

Static Methods (String.xxx)

Method Status Description
String.fromCodePoint(...codePoints) Implemented Creates string from code points (surrogate pairs)
String.fromCharCode(...codes) Implemented Creates string from UTF-16 code units
String.raw(template, ...subs) Implemented Raw template literal tag
String.escape(string) Implemented URL encoding (non-standard)

Character Access Methods

Method Status Description
charAt(index) Implemented Returns character at index
charCodeAt(index) Implemented Returns UTF-16 code unit
codePointAt(index) Implemented Returns code point (handles surrogates)
at(index) Implemented Relative indexing (ES2022)

Search Methods

Method Status Description
indexOf(searchValue, fromIndex) Implemented Finds first occurrence
lastIndexOf(searchValue, fromIndex) Implemented Finds last occurrence
includes(searchValue, fromIndex) Implemented Checks if contains substring
startsWith(searchValue, position) Implemented Checks prefix
endsWith(searchValue, length) Implemented Checks suffix
search(regexp) Implemented Symbol.search support

Substring Methods

Method Status Description
substring(start, end) Implemented Extracts substring (swaps if needed)
slice(start, end) Implemented Extracts substring (negative indices)
substr(start, length) Implemented Extracts by length (deprecated)

Transformation Methods

Method Status Description
concat(...strings) Implemented Concatenates strings
toLowerCase() Implemented Converts to lowercase
toUpperCase() Implemented Converts to uppercase
toLocaleLowerCase(locale) Implemented Locale-aware lowercase
toLocaleUpperCase(locale) Implemented Locale-aware uppercase
trim() Implemented Removes whitespace from both ends
trimStart() Implemented Removes leading whitespace
trimEnd() Implemented Removes trailing whitespace
repeat(count) Implemented Repeats string
padStart(targetLength, padString) Implemented Pads at start
padEnd(targetLength, padString) Implemented Pads at end
normalize(form) Implemented Unicode normalization (NFC/NFD/NFKC/NFKD)

Method Aliases

  • trimLeft() -> trimStart()
  • trimRight() -> trimEnd()

Pattern Matching Methods

Method Status Description
split(separator, limit) Implemented Symbol.split support
replace(pattern, replacement) Implemented RegExp and function replacer
replaceAll(pattern, replacement) Implemented Global replacement (ES2021)
match(regexp) Implemented Symbol.match support
matchAll(regexp) Implemented Symbol.matchAll iterator (ES2020)

Unicode / Well-Formedness Methods

Method Status Description
isWellFormed() Implemented Checks for lone surrogates (ES2024)
toWellFormed() Implemented Replaces lone surrogates with U+FFFD (ES2024)
localeCompare(that, locales, options) Implemented Locale-aware comparison

Iterator Support

Method Status Description
[Symbol.iterator]() Implemented Iterates by code point (not UTF-16)

HTML Wrapper Methods (Annex B - Deprecated)

Method Status Description
anchor(name) Implemented <a name="...">
big() Implemented <big>
blink() Implemented <blink>
bold() Implemented <b>
fixed() Implemented <tt>
fontcolor(color) Implemented <font color="...">
fontsize(size) Implemented <font size="...">
italics() Implemented <i>
link(href) Implemented <a href="...">
small() Implemented <small>
strike() Implemented <strike>
sub() Implemented <sub>
sup() Implemented <sup>

Implementation Notes

String Iteration

Strings iterate by code point, not UTF-16 code unit:

const emoji = "😀";  // U+1F600, surrogate pair
for (const char of emoji) {
    console.log(char);  // "😀" (single iteration)
}

RegExp Method Support

String methods delegate to Symbol methods on RegExp:

  • split() -> regexp[Symbol.split]()
  • match() -> regexp[Symbol.match]()
  • matchAll() -> regexp[Symbol.matchAll]()
  • replace() -> regexp[Symbol.replace]()
  • search() -> regexp[Symbol.search]()

Files

File Purpose
StdLib/String/StringConstructor.cs Static methods
StdLib/String/StringPrototype.cs Prototype methods
StdLib/String/StringHelper.cs Internal helpers

See Also

Clone this wiki locally