public class StringBuilder extends Object
Mutable builder used to efficiently assemble text.
Text is accumulated in a growable UTF-16 buffer. Capacity is measured in CodeUnit values, while logical positions and lengths count Unicode scalars. Appending is amortized linear in the appended text, without a String per chunk.
The builder produces regular Klyn String values. It therefore follows the same text contract as String:
size and length() count Unicode scalar values, not UTF-16 code units'\u0000' is ordinary embeddable textUse StringBuilder for text rendering, source generation and formatting. Do not use it as a binary buffer.
builder = StringBuilder()
builder.append("Bonjour ")
builder.append("π")
print(builder.toString())| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | isEmptyisEmpty as Boolean |
Returns true when no character is present. |
| public readonly property | sizesize as ULong |
Returns the number of Unicode scalar values in the string builder. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | StringBuilderStringBuilder(size as ULong = 256) |
Creates a new builder. |
| public | StringBuilderStringBuilder(value as String) |
Creates a new builder initialized with text. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | appendappend(char as CodeUnit) as StringBuilder |
Appends one UTF-16 code unit to the builder. |
| public | appendappend(notnull values as Char[], offset as Long = 0l, count as Long = -1l) as StringBuilder |
Appends a range of Unicode scalars without allocating intermediate text. |
| public | appendappend(value as Boolean) as StringBuilder |
Appends a boolean. |
| public | appendappend(value as Byte) as StringBuilder |
Appends an unsigned byte. |
| public | appendappend(value as Char) as StringBuilder |
Appends one Unicode scalar to the builder. |
| public | appendappend(value as Double) as StringBuilder |
Appends a double. |
| public | appendappend(value as Float) as StringBuilder |
Appends a float. |
| public | appendappend(value as Int) as StringBuilder |
Appends a signed integer. |
| public | appendappend(value as Long) as StringBuilder |
Appends a signed long. |
| public | appendappend(value as Object) as StringBuilder |
Appends the string representation of an object. |
| public | appendappend(value as SByte) as StringBuilder |
Appends a signed byte. |
| public | appendappend(value as Short) as StringBuilder |
Appends a signed short. |
| public | appendappend(value as String) as StringBuilder |
Appends a string. |
| public | appendappend(value as UInt) as StringBuilder |
Appends an unsigned integer. |
| public | appendappend(value as ULong) as StringBuilder |
Appends an unsigned long. |
| public | appendappend(value as UShort) as StringBuilder |
Appends an unsigned short. |
| public | clearclear() as StringBuilder |
Clears current content. |
| public | endsWith | Tests whether the current content ends with a suffix. |
| public | insertinsert(position as Long, char as CodeUnit) as StringBuilder throws IndexException |
Inserts one UTF-16 code unit. |
| public | insertinsert(position as Long, value as Boolean) as StringBuilder throws IndexException |
Inserts a boolean. |
| public | insertinsert(position as Long, value as Byte) as StringBuilder throws IndexException |
Inserts an unsigned byte. |
| public | insertinsert(position as Long, value as Char) as StringBuilder throws IndexException |
Inserts one Unicode scalar. |
| public | insertinsert(position as Long, value as Double) as StringBuilder throws IndexException |
Inserts a double. |
| public | insertinsert(position as Long, value as Float) as StringBuilder throws IndexException |
Inserts a float. |
| public | insertinsert(position as Long, value as Int) as StringBuilder throws IndexException |
Inserts a signed integer. |
| public | insertinsert(position as Long, value as Long) as StringBuilder throws IndexException |
Inserts a signed long. |
| public | insertinsert(position as Long, value as Object) as StringBuilder throws IndexException |
Inserts the string representation of an object. |
| public | insertinsert(position as Long, value as SByte) as StringBuilder throws IndexException |
Inserts a signed byte. |
| public | insertinsert(position as Long, value as Short) as StringBuilder throws IndexException |
Inserts a signed short. |
| public | insertinsert(position as Long, value as String) as StringBuilder throws IndexException |
Inserts a string at a given position. |
| public | insertinsert(position as Long, value as UInt) as StringBuilder throws IndexException |
Inserts an unsigned integer. |
| public | insertinsert(position as Long, value as ULong) as StringBuilder throws IndexException |
Inserts an unsigned long. |
| public | insertinsert(position as Long, value as UShort) as StringBuilder throws IndexException |
Inserts an unsigned short. |
| public | lengthlength() as ULong |
Returns current content length. |
| public | removeremove(position as Long, length as ULong) as StringBuilder throws IndexException |
Removes a range of characters. |
| public | reversereverse() as StringBuilder |
Reverses characters in place. |
| public | toCharArraytoCharArray() as Char[] |
Returns the content as Unicode scalar values. |
| public | toCodeUnitArraytoCodeUnitArray() as CodeUnit[] |
Returns the content as UTF-16 code units. |
| public override | toStringtoString() as String |
Returns a String representation of the builder content. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | operator[](position as Long) as Char throws IndexException | Gets or sets one Unicode scalar by index. |