Package-level declarations

Functions

Link copied to clipboard

Converts a camelCase or PascalCase string to a human-readable label. Example: "firstName".camelToTitle() → "First Name"

Link copied to clipboard

Collapses multiple consecutive whitespace characters to a single space. Example: "hello world\t!".collapseWhitespace() → "hello world !"

Link copied to clipboard

Decodes a Punycode-encoded label (without the xn-- prefix) to Unicode. Example: "mnchen-3ya".decodePunycode() → "münchen"

Link copied to clipboard

Encodes a Unicode label to Punycode (without the xn-- prefix). Example: "münchen".encodePunycode() → "mnchen-3ya"

Link copied to clipboard

Converts an ACE (xn--) domain name back to Unicode. Example: "xn--mnchen-3ya.de".fromAce() → "münchen.de"

Link copied to clipboard

Returns true if this string is a valid IDN (contains non-ASCII labels).

Link copied to clipboard

Converts a kebab-case string to a human-readable label. Example: "first-name".kebabToTitle() → "First Name"

Link copied to clipboard

Converts a snake_case string to a human-readable label. Example: "first_name".snakeToTitle() → "First Name"

Link copied to clipboard

Converts a Unicode domain name to its ASCII-compatible encoding (ACE / IDN). Example: "münchen.de".toAce() → "xn--mnchen-3ya.de"

Link copied to clipboard

Converts any string to camelCase. Example: "hello world".toCamelCase() → "helloWorld"

Link copied to clipboard

Extracts exactly the first and last initials from a full name. Example: "Jean-Claude Van Damme".toFirstLastInitials() → "JD"

Link copied to clipboard
fun String.toInitials(maxLetters: Int = 3): String

Extracts initials from a full name string. Example: "Jean-Claude Van Damme".toInitials() → "JVD"

Link copied to clipboard

Converts any string to kebab-case. Example: "Hello World".toKebabCase() → "hello-world"

Link copied to clipboard

Converts any string to snake_case. Example: "Hello World".toSnakeCase() → "hello_world"

Link copied to clipboard

Converts a String to title case. Example: "hello world".toTitleCase() → "Hello World"

Link copied to clipboard
fun String.truncate(maxLength: Int, ellipsis: String = "..."): String

Truncates a String to maxLength characters, appending ellipsis if truncated. Example: "Hello, World!".truncate(8) → "Hello..."

Link copied to clipboard
fun String.truncateLines(maxLines: Int, ellipsis: String = "..."): String

Truncates to maxLines lines, appending ellipsis on the last line if truncated. Example: "a\nb\nc\nd".truncateLines(2) → "a\nb..."

Link copied to clipboard
fun String.truncateMiddle(maxLength: Int, ellipsis: String = "..."): String

Truncates a String in the middle, preserving start and end. Example: "abcdefghij".truncateMiddle(7) → "ab...ij"

Link copied to clipboard
fun String.truncateWords(maxLength: Int, ellipsis: String = "..."): String

Truncates a String at the nearest word boundary within maxLength. Example: "Hello beautiful world".truncateWords(14) → "Hello..."

Link copied to clipboard
fun String.wordWrap(lineWidth: Int): String

Wraps a String to lineWidth characters, breaking at spaces. Example: "Hello world foo bar".wordWrap(10) → "Hello\nworld foo\nbar"