converted c string utils to lua

copy and paste of c file, and find replace of certain functions