Advertisement
ecco7777

Lua toUpper function

Dec 14th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.44 KB | None | 0 0
  1. function toUpper(str)
  2. local chars={A="a",B="b",C="c",D="d",E="e",F="f",G="g",H="h",I="i",J="j",K="k",L="l",M="m",N="n",O="o",P="p",Q="q",R="r",S="s",T="t",U="u",V="v",W="w",X="x",Y="y",Z="z"}
  3.     for i=1, #str do
  4.         if chars[string.sub(str,i,i)]~=nil then
  5.             if i==1 then
  6.             str=chars[string.sub(str,i,i)]..string.sub(str,2)
  7.             else
  8.             str=string.sub(str,1,i-1)..chars[string.sub(str,i,i)]..string.sub(str,i+1)
  9.             end
  10.         end
  11.     end
  12. return str
  13. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement