Refactor string.c Fix #2267

Revert changes  using STR_LEN() and RSTRING_PTR()
Fix #2267