Skip to content

v0.2.0

Choose a tag to compare

@DmitryNekrasov DmitryNekrasov released this 06 Oct 20:13
· 10 commits to main since this release

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/