mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-25 02:10:39 +01:00
Improve UTF-8 string length counting
This commit is contained in:
parent
c635343c9b
commit
9ab47fc0f0
@ -78,7 +78,13 @@ local function toupper(str)
|
||||
end
|
||||
|
||||
local function utf8_len(str)
|
||||
return #str:gsub("[\128-\191]", "") -- Arguably working duct-tape code
|
||||
local c = 0
|
||||
|
||||
for _ in str:gmatch"([%z\1-\127\194-\244][\128-\191]*)" do -- Arguably working duct-tape code
|
||||
c++
|
||||
end
|
||||
|
||||
return c
|
||||
end
|
||||
|
||||
local function get_bag_description(data, stack)
|
||||
|
Loading…
Reference in New Issue
Block a user