posted 8 years ago
Encodings are applicable to character streams, not binary streams. If you need to use an encoding when writing binary data, something else is going on. There are a few points I'm confused on. First, the & #149 codes are HTML entities, so for some reason something is HTML encoding your data, as if it thinks the data is intended to be the content of a web page. Also, the GET error you've reported is something you'd see in a web browser if something blew up on the server. Nothing in the OP indicates that you are servicing in a web app, so how did that get into the mix? Mis-encoding a stream wouldn't cause a 500 error, so that looks to be an entirely separate problem anyway.
Another point of confusion for me is where you use "Hex Editor Neo" to read the file, but you are not seeing hex output. That is, I would expect to see a series of hex numbers like 87 A3 22 1F, etc., instead of characters like tL.|, etc. In any case, where are you getting an original file to read from? Are you sure that the translation of bytes isn't happening during the read, as opposed to during the write?