Online text encoding and decoding