I have a heap allocated buffer which has a string that contains \n that I would like to add it to a json like format and send it across http protocol
Client side
char * str = malloc(4096);
/* added text to str */
char buffer[4096];
char format[] = "{ \"Result\": \"%s\" }";
sprintf(buffer, format, str);
// send to server
send_result(server, buffer);
On the server side I get http 500 because of the string containing \n which causes the json to be malformed and works fine if I use a string without the \n
is there a way to fix this without writing my own library to serialize the buffer, is there a builtin feature to do so, how does the winsock deal with such task
please do not mention open source projects, I am asking if there is something builtin c or the winapi