Implement String.encode/decode