I'm using Ubuntu 16.04LTS, HTML, PHP
I make C/C++/java/Python code marking web Site.
I submit this code in HTML
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d + %d = %d",a,b,a+b);
return 0;
}
this text in
<input type="hidden" name="code" id="code">
and use POST method go to PHP
$code = str_ireplace("\x0D", "\n", $_POST['code']);
but server open this code
#include <stdio.h> int main() { int a,b; scanf("%d %d",&a,&b); printf("%d + %d = %d",a,b,a+b); return 0; }
so I use ubuntu command "sed"
sed -e "s/^M/\n/g" $file > $newfile
but this result
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d + %d = %d",a,b,a+b);
return 0;
}
remove tab and add line first char space
How can I solve this problem?