Replace c string code with c++ versions (rebased)

This is the rebased version of https://github.com/WagicProject/wagic/pull/563