Any suggestions on how to get the number of displayed characters in a lua string that may contain utf8 chars?
#str & string.len(str) return the number of bytes rather than number of characters.
There is the utf8 string module in lua 5.3, but it's not found in game (not sure if Factorio is still on lua 5.2.x or if it's disabled?).
I'm trying to force some display padding and sorting behaviours.
Number of characters in utf8 string
Re: Number of characters in utf8 string
My first thought is to convert the string to . or A or some other known len() character with Lua patterns. Replace every character with the same and then measure length. Would be trivial in regex, but patterns must operate on the character level. Or look in documentation for a proper character length function if you don't want to make messy and bad code .
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser