encoding and decoding special characters properly