This string function encodes a string.