public class String:
The String class is used to store and manipulate textual content. Since it is mutable, a string may change over the course of program execution.
Klyn strings are textual values encoded in UTF-8 and terminated by an ASCII zero byte (AZT model). They are designed for text, not for arbitrary binary payloads.
Practical consequences:
size, indexing and slicing operate on Unicode scalar values, not onUTF-8 storage bytes.
U+0000 (Char(0)) is reserved as the end-of-stringmarker and cannot live inside a Klyn String.
not in String.
@example `klyn text = "Klyn UTF-8 : café / π" print(text)
@example ```klyn zero = String(Char(0)) assert zero.size == 0
@since 1.0
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | isEmptyisEmpty as Boolean: |
Returns true if the string is empty. |
| public readonly native property | sizesize as UInt |
Returns the number of characters in the string. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | StringString(): |
Builds the empty string. |
| public | String | Builds a one-character string from a Char. |
| public | String | Builds a string from a character array. |
| public | String | Builds a string from any object by using its textual representation. |
| Modifier and Type | Member | Description |
|---|---|---|
| public static | _slice | Internal helper used by the compiler to implement slice syntax. |
| public native | capitalizecapitalize() as String |
Capitalizes the string in place (first character only). |
| public | center | Centers this string to the target width. |
| public native | contains | Returns true if this string contains the provided substring. |
| public | count | Counts non-overlapping occurrences of a substring. |
| public | endsWith | Returns true if this string ends with the provided value. |
| public | endsWith | Returns true if this string ends with at least one suffix from the provided list. |
| public native | endsWith | Returns true if this string ends with the provided suffix. |
| public | equalsIgnoreCase | Compares two strings without case sensitivity. |
| public native | indexOf | Finds the first index of a substring starting from a position. |
| public | isAlnumisAlnum() as Boolean: |
Returns true if all characters are alphanumeric. |
| public | isAlphaisAlpha() as Boolean: |
Returns true if all characters are alphabetic. |
| public | isBlankisBlank() as Boolean: |
Returns true if the string is empty or only contains spaces. |
| public | isDigitisDigit() as Boolean: |
Returns true if all characters are digits. |
| public | isLowerisLower() as Boolean: |
Returns true if all cased characters are lowercase and at least one cased character exists. |
| public | isSpaceisSpace() as Boolean: |
Returns true if all characters are whitespace. |
| public | isUpperisUpper() as Boolean: |
Returns true if all cased characters are uppercase and at least one cased character exists. |
| public | join | Joins an array of characters using this string as separator. |
| public | join | Joins an array of strings using this string as separator. |
| public | join | Joins a list of strings using this string as separator. |
| public native | lastIndexOf | Finds the last index of a substring up to a position. |
| public | lowerlower() as String: |
Converts the string to lowercase in place. |
| public | lpad | Left pads this string to the target width. |
| public | ltrimltrim() as String: |
Removes leading whitespace in place. |
| public | matches | Tests the string against a regular expression. |
| public native | removeAccentsremoveAccents() as String |
Removes accents in place. |
| public native | removeSGR | Returns the string with ANSI SGR escape sequences removed. |
| public native | replace | Returns a copy where all occurrences of oldValue are replaced by newValue. |
| public native | replaceFirst | Returns a copy where the first occurrence of oldValue is replaced by newValue. |
| public native | replaceLast | Returns a copy where the last occurrence of oldValue is replaced by newValue. |
| public | rpad | Right pads this string to the target width. |
| public | rtrimrtrim() as String: |
Removes trailing whitespace in place. |
| public native | split | Splits the string using a string delimiter. |
| public native | startsWith | Returns true if this string starts with the provided prefix. |
| public | startsWith | Returns true if this string starts with the provided value. |
| public | startsWith | Returns true if this string starts with at least one prefix from the provided list. |
| public native | substringsubstring(start as Int, length as Int = -1) as String throws IndexException |
Extracts a substring. |
| public | titletitle() as String: |
Capitalizes each word in place. |
| public native | toCapitalizetoCapitalize() as String |
Returns a new string with the first character capitalized. |
| public | toLowertoLower() as String: |
Returns the string in lowercase. |
| public native | toRemoveAccentstoRemoveAccents() as String |
Returns a new string without accents. |
| public override | toStringtoString() as String: |
Returns this string (identity conversion). |
| public | toTitletoTitle() as String: |
Returns a title-cased copy of this string. |
| public | toTrimtoTrim() as String: |
Returns the string with leading and trailing whitespace removed. |
| public | toUppertoUpper() as String: |
Returns the string in uppercase. |
| public | trimtrim() as String: |
Removes leading and trailing whitespace in place. |
| public | upperupper() as String: |
Converts the string to uppercase in place. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native static | operator*( readonly first as String, readonly count as UInt ) as String | Repeats a string a given number of times. |
| public native | operator*=( readonly count as UInt ) as String | Repeats this string in place. |
| public native static | operator+( readonly first as String, readonly second as String ) as String | Concatenates two strings. |
| public native | operator+=( readonly second as String ) as String | Appends another string to this string (in place). |
| public native | operator[]( position as UInt ) as Char throws IndexException | Returns or sets the character at the given position. |