|
On 09/09/15 05:42 PM, Soni L. wrote:
local function normalizeOverlongAndSurrogates(s) local t = {} local i = 0 for p,c in utf8.codes(s) do i = i + 1 if c >= 0xD800 and c <= 0xDBFF then t[i] = {c-0xD800} -- errors on the table.concat elseif c >= 0xDC00 and c <= 0xDFFF then i = i - 1if type(t[i]) ~= "table" then error("Invalid surrogate sequence") endc = c - 0xDC00 local x = t[i] c = utf8.char(0x10000 + x * 0x400 + c) else t[i] = utf8.char(c) end end return table.concat(t, "", 1, i) end
Oh shit I did that wrong. Should be local x = t[i][1]. -- Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.