Added functions to encode/decode strings