Be more specific when we exit because of an unimplemented JNI call.

Also add basic char/string escaping functions for cleaning error messages.

Change-Id: I03df28e30a492bfd293ef6aa56a703ec87817ed5
diff --git a/src/utils.h b/src/utils.h
index 1da7c88..67038cf 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -4,6 +4,7 @@
 #define ART_SRC_UTILS_H_
 
 #include "globals.h"
+#include "stringprintf.h"
 
 namespace art {
 
@@ -95,6 +96,36 @@
   return static_cast<int>(x & 0x0000003F);
 }
 
+static inline std::string PrintableChar(uint16_t ch) {
+  std::string result;
+  if (ch >= ' ' && ch <= '~') {
+    // ASCII.
+    result += '\'';
+    result += ch;
+    result += '\'';
+    return result;
+  }
+  // Non-ASCII; show the code point.
+  StringAppendF(&result, "'\\u%04x'", ch);
+  return result;
+}
+
+template<typename StringT>
+static inline std::string PrintableString(const StringT& s) {
+  std::string result;
+  result += '"';
+  for (typename StringT::iterator it = s.begin(); it != s.end(); ++it) {
+    char ch = *it;
+    if (ch >= ' ' && ch <= '~') {
+      result += ch;
+    } else {
+      StringAppendF(&result, "\\x%02x", ch & 0xff);
+    }
+  }
+  result += '"';
+  return result;
+}
+
 }  // namespace art
 
 #endif  // ART_SRC_UTILS_H_