Repository navigation
Releases
v0.3.0
utf8-string is now tekst, a library for working with text by graphemes. Its grapheme boundaries now also work on a String or another CharSequence, at char indices, with no copy of the text.
isGraphemeBoundary,nextGraphemeBoundaryandpreviousGraphemeBoundaryextendCharSequence.startIndexandendIndexlimit a query to a part of the text, such as one line, and the query reads no char outside it.- A loop over the graphemes takes linear time when each call passes the last boundary as
startIndex. - Java calls them as
CharSequenceGraphemes.nextGraphemeBoundary(text, index).
The dependency is now io.github.dmitrynekrasov:tekst, and the package is tekst, so import utf8string.u8 becomes import tekst.u8. The Gradle plugin keeps its id, io.github.dmitrynekrasov.utf8-string, but its 0.3.0 encodes the literals of tekst 0.3.0 only, so update both versions together.
implementation("io.github.dmitrynekrasov:tekst:0.3.0")API reference: https://dmitrynekrasov.github.io/tekst/
v0.2.0
Random access to grapheme boundaries, iteration in both directions, and take and drop by graphemes. A position is a UTF-8 byte index, as in copyInto, and a count is a number of graphemes, as length is.
isGraphemeBoundary,nextGraphemeBoundaryandpreviousGraphemeBoundaryanswer at any byte index, without reading the text from its start.iterator(index)starts at the grapheme that contains the byte atindex.GraphemeIteratorhasindex,hasPrevious()andprevious(), andskipNext()andskipPrevious()move without creating aGrapheme.take,drop,takeLastanddropLastcount graphemes, so they never split a flag or an emoji with a skin tone, asString.takecan.
Your code may need a change in 2 cases: a reference such as text::iterator needs an expected type now that iterator has an overload, and the new members win over your own extensions with the same name and parameters, such as Utf8String.take(Int). The compiler plugin did not change.
implementation("io.github.dmitrynekrasov:utf8-string:0.2.0")API reference: https://dmitrynekrasov.github.io/utf8-string/
v0.1.1
Every public declaration now has a sample in the API reference. The code of the library and the compiler plugin did not change.
implementation("io.github.dmitrynekrasov:utf8-string:0.1.1")API reference: https://dmitrynekrasov.github.io/utf8-string/
v0.1.0
The first release.
Utf8String, an immutable Kotlin Multiplatform string stored as UTF-8 bytes. Itslengthcounts graphemes andforiterates over them, by the rules of Unicode 18.0 (UAX #29), with the same result on every target..u8andtoUtf8String()encode aString. With the compiler plugin,"...".u8on a constant string is encoded at compile time.- Targets: JVM, JS, Wasm (JS and WASI), and Kotlin/Native for Linux, macOS arm64, Windows, iOS, watchOS, and tvOS.
- The library needs Kotlin 2.4.20 or newer, and the compiler plugin works only with Kotlin 2.4.20.
implementation("io.github.dmitrynekrasov:utf8-string:0.1.0")API reference: https://dmitrynekrasov.github.io/utf8-string/