[C++] Fix newlines in $(info/warning/error)

Change-Id: Ia20a1ef563a6871ed843b9388fe27e87b8bd7020
diff --git a/strutil.cc b/strutil.cc
index ea5d633..defb292 100644
--- a/strutil.cc
+++ b/strutil.cc
@@ -427,3 +427,24 @@
   NormalizePath(&r);
   return r;
 }
+
+string EchoEscape(const string str) {
+  const char *in = str.c_str();
+  string buf;
+  for (; *in; in++) {
+    switch(*in) {
+      case '\\':
+        buf += "\\\\\\\\";
+        break;
+      case '\n':
+        buf += "\\n";
+        break;
+      case '"':
+        buf += "\\\"";
+        break;
+      default:
+        buf += *in;
+    }
+  }
+  return buf;
+}