Anyone know how to count Unicode glyphs in Vala?
Eg., “” = two glyphs
This is currently what I’m banging my head against.
To wit, what I’ve already tried:
- string.length returns bytes
- get_char_count() returns characters (eg. an emoji might be 5 characters)
- I can’t seem to find a way to split a string into an array of glyphs (in JavaScript: […str].length does the trick). e.g., string.split throws an error in Vala if called with an empty string as the delimiter.
@refi64 Thanks! I did try that last night but couldn’t initially find a way to get the length (and had to leave it as we’re prepping to move house).
Still, there must be a way to actually count glyphs as the text buffer’s cursor manages to properly…
@refi64 So I finally found a way to do it :) https://ar.al/2021/10/31/how-to-count-unicode-glyphs-in-vala-using-gtk/