Added logic to detect the encoding of a file (and use that) in the PN