mirror of
https://github.com/smogon/sprites.git
synced 2026-08-24 10:46:58 -05:00
Use utf8.char, tup supports lua 5.3 after all
Did it gain support in a later version? Or, was I imagining it only supporting 5.1 from the start?
This commit is contained in:
@@ -19,15 +19,3 @@ function astable(table)
|
||||
return {}
|
||||
end
|
||||
end
|
||||
|
||||
-- Lua 5.1, which ships with Tup, does not have a way of creating a string from
|
||||
-- a unicode codepoint...
|
||||
--
|
||||
-- https://stackoverflow.com/a/7799843
|
||||
function unichr(ord)
|
||||
if ord == nil then return nil end
|
||||
if ord < 32 then return string.format('\\x%02x', ord) end
|
||||
if ord < 126 then return string.char(ord) end
|
||||
if ord < 65539 then return string.format("\\u%04x", ord) end
|
||||
if ord < 1114111 then return string.format("\\u%08x", ord) end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
function decodeFS(filename)
|
||||
return filename:gsub('_(%x%x%x%x)',
|
||||
function(hex)
|
||||
return unichr(tonumber(hex, 16))
|
||||
return utf8.char(tonumber(hex, 16))
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user