Unicode Text Segmentation for MoonBit
moon add moonbit-community/unicode-segmentationtype Graphemestest {
let clusters = @segmentation.graphemes("e\u{301}x")
inspect(
clusters.next(),
content=(
#|é
),
)
inspect(
clusters.next(),
content=(
#|x
),
)
inspect(
clusters.next().is_empty(),
content=(
#|true
),
)
}test {
let clusters = []
for cluster in @segmentation.graphemes("e\u{301}🇺🇳x") {
clusters.push(cluster.to_owned())
}
debug_inspect(
clusters,
content=(
#|["é", "🇺🇳", "x"]
),
)
}Install
Download zipUnicode Text Segmentation for MoonBit