various string parsing & transformation utilities for kotlin
Find a file
Mey fa8a5fd337
Some checks failed
Java CI with Gradle / build (macos-latest, iosSimulatorArm64Test) (push) Has been cancelled
Java CI with Gradle / build (ubuntu-latest, jvmTest) (push) Has been cancelled
Java CI with Gradle / build (ubuntu-latest, linuxX64Test) (push) Has been cancelled
Java CI with Gradle / build (ubuntu-latest, testAndroidHostTest) (push) Has been cancelled
chore: readme, license
2025-12-28 22:13:51 -05:00
.github/workflows Initial commit 2025-12-29 02:11:32 +00:00
gradle chore: readme, license 2025-12-28 22:13:51 -05:00
library Initial commit 2025-12-29 02:11:32 +00:00
.gitignore Initial commit 2025-12-29 02:11:32 +00:00
build.gradle.kts Initial commit 2025-12-29 02:11:32 +00:00
gradle.properties Initial commit 2025-12-29 02:11:32 +00:00
gradlew Initial commit 2025-12-29 02:11:32 +00:00
gradlew.bat Initial commit 2025-12-29 02:11:32 +00:00
LICENSE chore: readme, license 2025-12-28 22:13:51 -05:00
README.md chore: readme, license 2025-12-28 22:13:51 -05:00
settings.gradle.kts Initial commit 2025-12-29 02:11:32 +00:00

Kenning

A compound expression in Old English and Old Norse poetry with metaphorical meaning.

e.g. oar-steed = ship

Parse complex strings into their most basic parts.

Say for example, you want to parse the R, G, B, A values from a hex string like #dc354580, in the format #RRGGBBAA. Somewhere else in your codebase, you might want to parse those same values, but this time, from the format #ARGB.

Let's draw it out:

// first scenario
val awtColor = parseHex(
    allowAlpha = true,
    // don't see why you would want to use options like this which inconvenience
    // your users more than help, but they're here for *your* convenience.
    allowShorthand = false,
    order = HexOrder.RGBA,
    requireHash = false
) { (r: Int, g: Int, b: Int, a: Int) -> { // outputs: always in the same order
    // do something with the color, in this scenario we will construct a
    // java.awt.Color
    
    java.awt.Color(r, g, b, a)
} }

License

This project is provided freely under the terms of the MIT License.