1
I have a program in Python that receives a binary file via parameter and saves this file. However, when it saves the file, some characters it replaces with a series of numbers. Below the original file I receive as parameter:
ÐT_Ö/ ːæ ®kMµûSoz"Ô(Î,"+œd¼Es
But when the program records, look at the result:
ÐT_Ö/ ːæ ®kMµûSoz & #148 ; Ô(Î, & #147 ; & #156 ;d¼Es
You can see that character " between the characters z and Ô has been replaced by the sequence of & # 148;. Also the character + between characters Î and andd has been replaced by the & # 147
Below the code of the program Python that do the milking and recording binary file
import subprocess
from subprocess import Popen, PIPE, STDOUT
def chamaProg(arquivo):
var_file = open("C:\\Nitgen\\arquivo.rec","wb")
conteudo_texto = var_file.write(arquivo)
var_file.close(
Why is this happening?
What should I do to read and write all characters correctly?
Please, I need to resolve this problem urgently.
Thank you.
If the recording is binary, it should not - nor does it make sense - be used an encoding.
– jsbueno