local isCombining = function (codepoint)
return
(codepoint >= 0x0300 and codepoint <= 0x036F)
or (codepoint >= 0x1AB0 and codepoint <= 0x1AFF)
or (codepoint >= 0x1DC0 and codepoint <= 0x1DFF)
or (codepoint >= 0x20D0 and codepoint <= 0x20FF)
or (codepoint >= 0x2DE0 and codepoint <= 0x2DFF)
or (codepoint >= 0xFE20 and codepoint <= 0xFE2F)
or false
end
local nonCombining = {
[0x0300] = 0x0060, [0x0301] = 0x00B4, [0x0302] = 0x02C6, [0x0303] = 0x007E, [0x0304] = 0x00AF, [0x0305] = 0x203E, [0x0306] = 0x02D8, [0x0307] = 0x02D9, [0x0308] = 0x00A8, [0x030A] = 0x02DA, [0x030B] = 0x02DD, [0x030C] = 0x02C7, [0x0312] = 0x00B8, [0x0316] = 0x0060, [0x0317] = 0x00B4, [0x031F] = 0x002B, [0x0320] = 0x002D, [0x0323] = 0x002E, [0x0324] = 0x00A8, [0x0327] = 0x00B8, [0x0328] = 0x02DB, [0x032C] = 0x02C7, [0x032D] = 0x005E, [0x032E] = 0x02D8, [0x0330] = 0x007E, [0x0331] = 0x00AF, [0x0332] = 0x203E, [0x0333] = 0x2017, [0x0338] = 0x002F, [0x034D] = 0x2194, [0x20D0] = 0x21BC, [0x20D1] = 0x21C0, [0x20D6] = 0x2190, [0x20D7] = 0x2192, [0x20DB] = 0x22EF, [0x20E1] = 0x2194, [0x20E8] = 0x22EF, [0x20EC] = 0x21C1, [0x20ED] = 0x21BD, [0x20EE] = 0x2190, [0x20EF] = 0x2192, }
local function makeNonCombining (char)
local codepoint = luautf8.codepoint(char, 1)
if isCombining(codepoint) then
local noncombining = nonCombining[codepoint]
if noncombining then
return luautf8.char(noncombining)
end
SU.warn(("No non-combining equivalent for codepoint 0x%x"):format(codepoint))
end
return char
end
return {
isCombining = isCombining,
makeNonCombining = makeNonCombining,
}