StringUnits.jl

Unit Types for Indexing Strings
Author mnemnion
Popularity
15 Stars
Updated Last
4 Months Ago
Started In
March 2024

StringUnits

Stable Dev Build Status Aqua codecov

StringUnits.jl is a package which provides units for indexing strings: by codeunit, by character, by grapheme, and by textwidth.

julia> str = "aฮป๐Ÿค”โˆ…๐Ÿ‘จ๐Ÿปโ€๐ŸŒพ!"
"aฮป๐Ÿค”โˆ…๐Ÿ‘จ๐Ÿป\u200d๐ŸŒพ!"

julia> str[3ch]
'๐Ÿค”': Unicode U+1F914 (category So: Symbol, other)

julia> str[1cu]
0x61

julia> str[5gr]
"๐Ÿ‘จ๐Ÿป\u200d๐ŸŒพ"

julia> str[2ch:4ch]
"ฮป๐Ÿค”โˆ…"

julia> str[2ch:5ch + 0gr]
"ฮป๐Ÿค”โˆ…๐Ÿ‘จ๐Ÿป\u200d๐ŸŒพ"

For details, see the documentation