Code: Select all
function Unicode(inString)
if inString == '' then return end
newString = string.gsub(inString, '\\u(%x+)', '\[\\x%1\]')
return newString
end
The only thing that would still fool it is a something like some text\u29and some more text, where 29 ) and 29a ʚ are both valid hex numbers and valid Unicode characters. This Lua will choose the later... I doubt you would ever see that, as the standard for using escapes to encode Unicode in HTML is that it must be followed by a space if the next character is one of a-f, A-F, 0-9.