Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set = set or 1
- mode = mode or 1
- USET = {0x1D400,0x1D538,0x1D5A0,0x1D5D4,0x1D670,0x1D4D0,0x1D504,0x1D56C}
- NSET = {0x1D7EC,0x1D7D8,0x1D7E2,0x1D7EC,0x1D7F6, nil, nil, nil}
- 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="ᛎ"}
- if USET[set] == nil then error("Chosen set does not exist.",0) end
- if txt == nil then error("Please define txt variable",0) end
- U=USET[set]
- N=NSET[set]
- local o
- modes={}
- modes[1] = function()
- o=txt:gsub("%l",function(t) return z(U+t:byte()-71) end):gsub("%u",function(t) return z(U+t:byte()-65) end)
- if N ~= nil then
- o = o:gsub("%d",function(t) return z(N+t:byte()-48) end)
- end
- end
- modes[2] = function()
- 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)
- end
- modes[3] = function()
- o=txt:lower():gsub(".",function(t) return runetable[t] or t end)
- end
- if modes[mode] == nil then error("Chosen mode does not exist.",0) end
- function z(val)
- local size = val < 0x10000 and (val < 0x800 and (val < 0x80 and 1 or 2) or 3) or 4
- if size == 1 then return string.char(val) end
- local b = {string.char((240*2^(4-size)%256)+(val/2^(size*6-6))%(2^(7-size)))}
- for i = size*6-12,0,-6 do
- b[#b+1] = string.char(128+(val/2^i)%64)
- end
- return table.concat(b)
- end
- function uz(stuff)
- b = { stuff:byte(1,-1) }
- if #b == 1 then return b[1] end
- c = b[1]%(8*(2^(4-#b)))*(2^(6*#b-6))
- for i = 2,#b do
- c = c + (b[i]%64)*2^(6*(#b-i))
- end
- return c
- end
- modes[mode]()
- if a ~= nil then
- return a(o)
- else
- return o
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement