Advertisement
gamax92

Unifonts

Jul 14th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1.  
  2. set = set or 1
  3. mode = mode or 1
  4. USET = {0x1D400,0x1D538,0x1D5A0,0x1D5D4,0x1D670,0x1D4D0,0x1D504,0x1D56C}
  5. NSET = {0x1D7EC,0x1D7D8,0x1D7E2,0x1D7EC,0x1D7F6,    nil,    nil,    nil}
  6. runetable = {a="ᚨ",b="ᛑ",c="ᛍ",d="ᛑ",e="ᛂ",f="ᚠ",g="ᚵ",h="ᚻ",i="ᛁ",j="ᛂ",k="ᚲ",l="ᛚ",m="ᛘ",n="ᚾ",o="ᚮ",p="ᛈ",q="ᛩ",r="ᚱ",s="ᛊ",t="ᛏ",u="ᚢ",v="ᚡ",w="ᚥ",x="ᛪ",y="ᚤ",z="ᛎ"}
  7. if USET[set] == nil then error("Chosen set does not exist.",0) end
  8. if txt == nil then error("Please define txt variable",0) end
  9. U=USET[set]
  10. N=NSET[set]
  11. local o
  12. modes={}
  13. modes[1] = function()
  14.     o=txt:gsub("%l",function(t) return z(U+t:byte()-71) end):gsub("%u",function(t) return z(U+t:byte()-65) end)
  15.     if N ~= nil then
  16.         o = o:gsub("%d",function(t) return z(N+t:byte()-48) end)
  17.     end
  18. end
  19. modes[2] = function()
  20.     o=txt:gsub(".",function(t) local b = t:byte() if b >= 33 and b <= 126 then return z(0xFF00+b-32) else return t end end)
  21. end
  22. modes[3] = function()
  23.     o=txt:lower():gsub(".",function(t) return runetable[t] or t end)
  24. end
  25. if modes[mode] == nil then error("Chosen mode does not exist.",0) end
  26. function z(val)
  27.     local size = val < 0x10000 and (val < 0x800 and (val < 0x80 and 1 or 2) or 3) or 4
  28.     if size == 1 then return string.char(val) end
  29.     local b = {string.char((240*2^(4-size)%256)+(val/2^(size*6-6))%(2^(7-size)))}
  30.     for i = size*6-12,0,-6 do
  31.         b[#b+1] = string.char(128+(val/2^i)%64)
  32.     end
  33.     return table.concat(b)
  34. end
  35. function uz(stuff)
  36.     b = { stuff:byte(1,-1) }
  37.     if #b == 1 then return b[1] end
  38.     c = b[1]%(8*(2^(4-#b)))*(2^(6*#b-6))
  39.     for i = 2,#b do
  40.         c = c + (b[i]%64)*2^(6*(#b-i))
  41.     end
  42.     return c
  43. end
  44. modes[mode]()
  45. if a ~= nil then
  46.     return a(o)
  47. else
  48.     return o
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement