code: private String escapeSpecialChars(final String s) {
          char c;
          final StringBuffer so = new StringBuffer();
  
          final int len = s.length();
          for (int i = 0; i < len; i++) {
              c = s.charAt(i);
  
              /*
               * note that some of these escape sequences are unique to Erlang,
               * which is why the corresponding 'case' values use octal. The
               * resulting string is, of course, in Erlang format.
               */
  
              switch (c) {
              // some special escape sequences
              case '\b':
                  so.append("\\b");
                  break;
  
              case 0177:
                  so.append("\\d");
                  break;
  
              case 033:
                  so.append("\\e");
                  break;
  
              case '\f':
                  so.append("\\f");
                  break;
  
              case '\n':
                  so.append("\\n");
                  break;
  
              case '\r':
                  so.append("\\r");
                  break;
  
              case '\t':
                  so.append("\\t");
                  break;
  
              case 013:
                  so.append("\\v");
                  break;
  
              case '\\':
                  so.append("\\\\");
                  break;
  
              case '\'':
                  so.append("\\'");
                  break;
  
              case '\"':
                  so.append("\\\"");
                  break;
  
              default:
                  // some other character classes
                  if (c < 027) {
                      // control chars show as "\^@", "\^A" etc
                      so.append("\\^" + (char) ('A' - 1 + c));
                  } else if (c > 126) {
                      // 8-bit chars show as \345 \344 \366 etc
                      so.append("\\" + Integer.toOctalString(c));
                  } else {
                      // character is printable without modification!
                      so.append(c);
                  }
              }
          }
          return new String(so);
      }
docs: /*
  Get the atom string, with special characters escaped. Note that this
  function currently does not consider any characters above 127 to be
  printable.