Skip to content

Instantly share code, notes, and snippets.

@mabako
Created June 28, 2012 18:37
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mabako/3013120 to your computer and use it in GitHub Desktop.
lua € thing, unicode(like utf16)->utf8
:gsub("&#%d%d%d%d;", decode)
function decode(str)
local num = tonumber(str:sub(3,6))
local first = math.floor(num/4096)
num = num - 4096 * first
return string.char(first+224, math.floor(num/64)+128, num%64+128)
end
@qaisjp
Copy link

qaisjp commented Jul 11, 2012

Um, what is this for?

@mabako
Copy link
Author

mabako commented Jul 13, 2012

Converting "this is 9.99&# 8364; of stuff" (unnecessary space between # and 8, cause Github wouldn't show it correctly) to "this is 9.99€ worth of stuff", i.e. a simple unicode conversion for what concerns decimal representations. Not entirely tested out, that said, no hex support either. Was made on a request :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment