Figuring out encoding, escaping etc.