Encode/Decode Functions

Each of the following functions will encode a string according the rules of the given data format.