problem sending character(0x00)between 2 arduini uno using 2 hc05 modules

i have arduino->hc05 tx module and hc05->arduino rx module to transfer a text/docx file.I am unable to transfer data reliably.Once the pattern (0x00) is encountered the previos data repeats.If (0x00) is not encountered then there is no problem.I am reading file from PC and sending to serial port of arduino in Python.Python reads and writes data to hc05.I tried the solution mentioned in the forum as(byte(0x00)) and but the problem remains same

Code in Pyhthon f:

import sys
import serial
import time
import os


#make a serial port object
ser = serial.Serial('COM4', 9600, timeout= None)
time.sleep(2)  

f = open("C:\\Users\\game\\Desktop\\Python\\examples\\data.docx",mode = 'rb')

path = "C:\\Users\\game\\Desktop\\Python\\examples\\data.docx"
size = os.path.getsize(path)

blocksize = 16;
piece = int(size/blocksize);

print(piece)

ser.write(str(size).encode())
time.sleep(1)
  
for k in range(piece):
        time.sleep(0.05)
        value = f.read(blocksize)
        print(value) 
        print(k)
        print()         
        time.sleep(1)
        ser.write(value)
 
left_piece = size % blocksize
print(left_piece) 
value = f.read(left_piece)
ser.write(value)
ser.close()

Arduino code for Master:

#include<SoftwareSerial.h>
#include <stdio.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>     

SoftwareSerial BTSerial(10,11); // (10, 11);RX | TX

uint8_t char_to_read[20];
String size_file;
int piece,left_piece;
uint8_t size1;
int blocksize = 16;

void setup()
{
  Serial.begin(9600);
  BTSerial.begin(9600);
}

void loop()
{ 
   while (Serial.available() == 0)  {}

        size_file = Serial.readString();
       
        size1 = size_file.toInt();
        BTSerial.print(size_file);    
             
        piece = (size1/blocksize);
        left_piece = (size1 % blocksize);

        
       for(int x =0;x<piece;x++)
         {            
              for(int y=0;y<blocksize;y++)
                  {
                    while (Serial.available() == 0)  {}                
                    char_to_read[y] = Serial.read();
                  }
    BTSerial.write(char_to_read,16);
                                     
         }

         for(int y=0;y<left_piece;y++)
                  {
                    while (Serial.available() == 0)  {}
                     char_to_read[y] = Serial.read();
                  }
                  BTSerial.write(char_to_read,left_piece);               
       
}

Arduino code for slave:

#include<SoftwareSerial.h>
#include<string.h>
#include<stdio.h>
#include<stdint.h>
#include<ctype.h>

String rx, file_size1;
int i =0,j=0,z;
uint8_t rcv_array[20];
uint8_t file_size = 0;
int file1;
int blocksize=16;

SoftwareSerial BTSerial(10,11);  //10--RX 11--TX

void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
   BTSerial.begin(9600);

}

void loop() {
      {
       while (BTSerial.available() == 0) {}
    
 file_size1 = BTSerial.readString();
 file1 = file_size1.toInt();
 Serial.print(file1);
 Serial.println();
      }
       
      int piece = file1/blocksize;
      int left_piece = file1%blocksize;
      


    for(int x = 0;x < piece;x++)
          {  

            for(int y = 0;y <blocksize;y++)
                  {
                  
                     while(BTSerial.available() == 0) {}
                     
                      rcv_array[y] = BTSerial.read();
                      if (rcv_array[y] <0x10)
                          Serial.print("0");
                      Serial.print(rcv_array[y],HEX);                     
                  }
                  Serial.println();
                  Serial.print(x);
                  Serial.println();
                  Serial.print(x);
            
          }

// ///////////////for left_over characters///////////////

       for(int z = 0;z < left_piece;z++)
          {
                while(BTSerial.available() == 0) {}
                rcv_array[z] = BTSerial.read();
                if (rcv_array[z] <0x10)
                      Serial.print("0");
                      Serial.print(rcv_array[z],HEX);
           }       
}

I have attached the screenshot of the Serial monitor

I suspect that if you want to send data that includes the byte value 0 it would be better to treat the data in both Arduinos as an array of bytes (aka uint8_t) rather than as a String.

In any case it is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time.

You may also want to consider how the Arduinos can tell where a message begins and ends. If you are sending text that can be managed easily by having a character as a start-marker and another as an end-marker. However it's not so simple if the message could contain any byte value from 0 to 255.

...R

Thanks for the reply.Your suggestion of not using String object was helpful.It solved my problem.