title: How to remove ^M ^J characters in linux
body: <p>I have an external machine which send me results in my Raspberry pi. In my emulator Cutecom I have the results line by line without problems. I use Codeblocks and I wrote my own C application to read these data every 10 seconds. But something strange happens. Sometimes I have the results line by line and sometimes I have the strange characters ^M ^J at the end of each line and as a result I have terrible finals results. I think that these EOF characters are because the external machine has developed in Windows.</p>
  
  <p>The good results</p>
  
  <pre><code>+PARAMETERS: 45 BYTES FROM 0000:0000 (063)
  MACHINE_1:(AN=23.45,H=34.56,D=12.34)
  </code></pre>
  
  <p>The bad results</p>
  
  <pre><code>+PARAMETERS: 45 BYTES FROM 0000:0000 (063)^M^JMACHINE_1:
  (AN=21.45,H=33.56,D=10.34)
  </code></pre>
  
  <p>Ok, until here the only problem is the way the command line shows the result but my results are ok. But if I try to use strtok to get some tokens then I have serious problems because of these characters. What can I do? Can I add something to escape these characters?This is the part of the code which I use to read data from the machine</p>
  
  <pre><code>char buff[300];
  memset(buff, 0, sizeof(buff));
  for (;;)
  {
    n=read(fd,buff,sizeof(buff));
    sleep(1);
    printf("%s", buff);
    printf("\n");
    ....
    ....
  </code></pre>