Skip to content

Releases

v0.3.0

Choose a tag to compare

@DmitryNekrasov DmitryNekrasov released this 07 Oct 18:28

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, nextGraphemeBoundary and previousGraphemeBoundary extend CharSequence. startIndex and endIndex limit 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

Choose a tag to compare

@DmitryNekrasov DmitryNekrasov released this 06 Oct 20:13

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, nextGraphemeBoundary and previousGraphemeBoundary answer at any byte index, without reading the text from its start.
  • iterator(index) starts at the grapheme that contains the byte at index.
  • GraphemeIterator has index, hasPrevious() and previous(), and skipNext() and skipPrevious() move without creating a Grapheme.
  • take, drop, takeLast and dropLast count graphemes, so they never split a flag or an emoji with a skin tone, as String.take can.

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

Choose a tag to compare

@DmitryNekrasov DmitryNekrasov released this 03 Oct 19:55

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

Choose a tag to compare

@DmitryNekrasov DmitryNekrasov released this 03 Oct 12:40

The first release.

  • Utf8String, an immutable Kotlin Multiplatform string stored as UTF-8 bytes. Its length counts graphemes and for iterates over them, by the rules of Unicode 18.0 (UAX #29), with the same result on every target.
  • .u8 and toUtf8String() encode a String. With the compiler plugin, "...".u8 on 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/