generated from mey/kotlin-multiplatform-library-template
various string parsing & transformation utilities for kotlin
- Kotlin 100%
|
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
|
||
|---|---|---|
| .github/workflows | ||
| gradle | ||
| library | ||
| .gitignore | ||
| build.gradle.kts | ||
| gradle.properties | ||
| gradlew | ||
| gradlew.bat | ||
| LICENSE | ||
| README.md | ||
| settings.gradle.kts | ||
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.