StringsStrings in Seen are UTF-8 encoded, represented as {len: Int, data: ptr}.

Strings

String

Strings in Seen are UTF-8 encoded, represented as {len: Int, data: ptr}.

String Interpolation

let name = "World"
println("Hello, {name}!")
println("2 + 2 = {2 + 2}")

Operators

let greeting = "Hello, " + "World!"     // concatenation
let equal = "abc" == "abc"              // equality
let notEqual = "abc" != "xyz"           // inequality

Length

let s = "hello"
let len = s.length()           // byte length: 5

Character Access

let ch = seen_char_at(s, 0)   // Unicode code point at index
let byte = seen_byte_at(s, 0) // raw byte at index

String Functions

Prefix, suffix, search, count, split, and replace helpers scan byte indexes directly and allocate only the returned pieces or rebuilt result. Common prefix/suffix and substring probes use runtime byte-search fast paths, including a single-byte memchr path for delimiter-heavy workloads.

FunctionSignatureDescription
split(text: String, delimiter: String) r: Array<String>Split by delimiter
trim(text: String) r: StringRemove leading/trailing whitespace
startsWith(text: String, prefix: String) r: BoolCheck prefix
endsWith(text: String, suffix: String) r: BoolCheck suffix
contains(text: String, needle: String) r: BoolCheck substring
indexOf(text: String, needle: String, start: Int) r: IntFind first occurrence (-1 if not found)

Runtime String Functions

FunctionSignatureDescription
seen_str_concat_ss(a: String, b: String) r: StringConcatenate
seen_str_eq_ss(a: String, b: String) r: BoolEquality
seen_substring(s: String, start: Int, end: Int) r: StringSubstring extraction
seen_int_to_string(n: Int) r: StringInt to string
seen_float_to_string(f: Float) r: StringFloat to string
seen_char_to_str(c: Int) r: StringChar code point to string

Stdlib String Functions

FunctionSignatureDescription
String_toUpperCase(s: String) r: StringUppercase conversion
String_toLowerCase(s: String) r: StringLowercase conversion
String_toInt(s: String) r: IntParse as integer
String_toFloat(s: String) r: FloatParse as float
String_reverse(s: String) r: StringReverse string
String_isEmpty(s: String) r: IntCheck if empty
String_count(s: String, needle: String) r: IntCount occurrences
String_replace(s: String, old: String, new: String) r: StringReplace all occurrences
String_fromCharCode(code: Int) r: StringCreate from Unicode code point

Extended String Functions (seen_std/src/str/)

FunctionSignatureDescription
trimStart(s: String) r: StringTrim leading whitespace
trimEnd(s: String) r: StringTrim trailing whitespace
lastIndexOf(s: String, needle: String) r: IntLast occurrence
lines(s: String) r: Array<String>Split into lines
splitWhitespace(s: String) r: Array<String>Split on whitespace
words(s: String) r: Array<String>Split into words
replaceFirst(s: String, old: String, new: String) r: StringReplace first occurrence
removePrefix(s: String, prefix: String) r: StringRemove prefix if present
removeSuffix(s: String, suffix: String) r: StringRemove suffix if present
ensurePrefix(s: String, prefix: String) r: StringAdd prefix if missing
ensureSuffix(s: String, suffix: String) r: StringAdd suffix if missing
padStart(s: String, len: Int, ch: Char) r: StringPad start
padEnd(s: String, len: Int, ch: Char) r: StringPad end
repeat(s: String, n: Int) r: StringRepeat N times
join(arr: Array<String>, sep: String) r: StringJoin with separator

StringBuilder

Efficient string building with amortized allocation. repeat, join, split, and compiler-facing builder paths use this instead of repeated string concatenation for large outputs. toString() flattens the accumulated parts through a one-pass runtime helper.

import str.string

Constructor

let sb = StringBuilder.new()

Methods

MethodReturnDescription
append(text: String)VoidAppend string
tryAppend(text: String)Result<Unit, AllocError>Append after checking the current memory budget
appendChar(ch: Char)VoidAppend character
appendLine(text: String)VoidAppend string + newline
appendAll(values: Array<String>)VoidAppend all strings
clear()VoidClear contents
isEmpty()BoolCheck if empty
length()IntGet total length
toString()StringBuild final string with a linear flatten pass
tryToString()Result<String, AllocError>Build after checking the current memory budget
writeToFile(path: String)BoolStream builder parts to a file
buildAndClear()StringBuild string and clear builder

Example

let sb = StringBuilder.new()
sb.append("Hello")
sb.append(", ")
sb.append("World!")
let result = sb.toString()  // "Hello, World!"

Character Functions

FunctionSignatureDescription
Char_isDigit(c: Int) r: IntIs digit [0-9]
Char_isAlpha(c: Int) r: IntIs alphabetic [A-Za-z]
Char_isAlphanumeric(c: Int) r: IntIs alphanumeric
Char_isUpperCase(c: Int) r: IntIs uppercase
Char_isLowerCase(c: Int) r: IntIs lowercase
Char_isWhitespace(c: Int) r: IntIs whitespace
Char_toUpperCase(c: Int) r: IntTo uppercase
Char_toLowerCase(c: Int) r: IntTo lowercase
Char_toInt(c: Int) r: IntCharacter to integer (identity)
Architected in Kotlin. Rendered with Materia. Powered by Aether.
© 2026 Yousef.