StringBuilder
class in package klyn

    public class StringBuilder extends Object:

Object
└ StringBuilder

Mutable builder used to efficiently assemble text.

This implementation is optimized for repeated append operations by storing chunks and materializing a single string only when needed.

The builder produces regular Klyn `String` values. It therefore follows the same text contract as `String`:

- textual content is encoded in UTF-8
- `size` and `length()` count Unicode scalar values, not UTF-8 bytes
- strings are AZT (ASCII zero terminated)
- `Char(0)` is treated as an end-of-string marker, not as embeddable text

Use `StringBuilder` for text rendering, source generation and formatting. Do not use it as a binary buffer.

@example ```klyn builder = StringBuilder() builder.append("Bonjour ") builder.append("π") print(builder.toString())

    @since 1.0

Properties

Modifier and Type | Member | Description
--- | --- | ---
public readonly property | isEmpty `isEmpty as Boolean:` | Returns true when no character is present.
public readonly property | size `size as UInt:` | Returns the number of characters in the string builder.

Properties inherited from Object: type
Constructors

Modifier and Type | Member | Description
--- | --- | ---
public | StringBuilder `StringBuilder(size as UInt = 256):` | Creates a new builder.
public | StringBuilder `StringBuilder(value as String):` | Creates a new builder initialized with text.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public | append `append(char as Char) as StringBuilder:` | Appends one character to the builder.
public | append `append(value as Boolean) as StringBuilder:` | Appends a boolean.
public | append `append(value as Byte) as StringBuilder:` | Appends an unsigned byte.
public | append `append(value as Double) as StringBuilder:` | Appends a double.
public | append `append(value as Float) as StringBuilder:` | Appends a float.
public | append `append(value as Int) as StringBuilder:` | Appends a signed integer.
public | append `append(value as Long) as StringBuilder:` | Appends a signed long.
public | append `append(value as Object) as StringBuilder:` | Appends the string representation of an object.
public | append `append(value as SByte) as StringBuilder:` | Appends a signed byte.
public | append `append(value as Short) as StringBuilder:` | Appends a signed short.
public | append `append(value as String) as StringBuilder:` | Appends a string.
public | append `append(value as UInt) as StringBuilder:` | Appends an unsigned integer.
public | append `append(value as ULong) as StringBuilder:` | Appends an unsigned long.
public | append `append(value as UShort) as StringBuilder:` | Appends an unsigned short.
public | clear `clear() as StringBuilder:` | Clears current content.
public | insert `insert(position as UInt, char as Char) as StringBuilder throws IndexException:` | Inserts one character.
public | insert `insert(position as UInt, value as Boolean) as StringBuilder throws IndexException:` | Inserts a boolean.
public | insert `insert(position as UInt, value as Byte) as StringBuilder throws IndexException:` | Inserts an unsigned byte.
public | insert `insert(position as UInt, value as Double) as StringBuilder throws IndexException:` | Inserts a double.
public | insert `insert(position as UInt, value as Float) as StringBuilder throws IndexException:` | Inserts a float.
public | insert `insert(position as UInt, value as Int) as StringBuilder throws IndexException:` | Inserts a signed integer.
public | insert `insert(position as UInt, value as Long) as StringBuilder throws IndexException:` | Inserts a signed long.
public | insert `insert(position as UInt, value as Object) as StringBuilder throws IndexException:` | Inserts the string representation of an object.
public | insert `insert(position as UInt, value as SByte) as StringBuilder throws IndexException:` | Inserts a signed byte.
public | insert `insert(position as UInt, value as Short) as StringBuilder throws IndexException:` | Inserts a signed short.
public | insert `insert(position as UInt, value as String) as StringBuilder throws IndexException:` | Inserts a string at a given position.
public | insert `insert(position as UInt, value as UInt) as StringBuilder throws IndexException:` | Inserts an unsigned integer.
public | insert `insert(position as UInt, value as ULong) as StringBuilder throws IndexException:` | Inserts an unsigned long.
public | insert `insert(position as UInt, value as UShort) as StringBuilder throws IndexException:` | Inserts an unsigned short.
public | length `length() as UInt:` | Returns current content length.
public | remove `remove(position as UInt, length as UInt) as StringBuilder throws IndexException:` | Removes a range of characters.
public | reverse `reverse() as StringBuilder:` | Reverses characters in place.
public | toCharArray `toCharArray() as Char[]:` | Returns the content as a character array.
public override | toString `toString() as String:` | Returns a String representation of the builder content.

Methods inherited from Object: fromJson, toDict, toJson, toString, toXml
Operators

Modifier and Type | Member | Description
--- | --- | ---
public | operator[](position as UInt) as Char throws IndexException: | Gets or sets one character by index.