Added method to encode data from unicode