Updated code

Started detecting and converting text, based on its encoding.