misc: Add a function to encode newlines
Given a string, the added function encodes existing newline characters
('\n') as the string "\\n" and puts into a given output buffer.
The output buffer must have at least 2 times the length of the input
string plus 1 for the terminating '\0'. In the worst case, each
character can be replaced by 2 characters.
Signed-off-by: Anderson Toshiyuki Sasaki <email@example.com>
Reviewed-by: Andreas Schneider <firstname.lastname@example.org>
Reviewed-by: Jakub Jelen <email@example.com>