better handling of text encoding