Corona

[CC] StringManager Utility

Apr 12th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. --[[
  2.   Software engineered and maintained by Coronaxe,
  3.   please provide original author name when
  4.   altering or redistributing this software!
  5.   Thank you!
  6. ]]--
  7.  
  8. function StrToByteArr( str )
  9.   local tBytes = {}
  10.   for i = 1, #str do
  11.     table.insert(tBytes,str:byte(i,i))
  12.   end
  13.   return tBytes
  14. end
  15.  
  16. function StrToNumber( str )
  17.   local bytestr = 0
  18.   for i = 1, #str do
  19.     bytestr = bytestr + string.byte(string.sub(str, i, i+1))
  20.   end
  21.   return bytestr
  22. end
  23.  
  24. function ByteArrToStr( tBytes )
  25.     local str = ""
  26.     for i = 1, #tBytes do
  27.       str = str .. string.char( tBytes[i] )
  28.     end
  29.     return str
  30. end
  31.  
  32. function ArrToStr( tArr )
  33.     local str = ""
  34.     for i = 1, #tArr do
  35.       str = str .. tArr[i]
  36.     end
  37.     return str
  38. end
Add Comment
Please, Sign In to add comment