code: private String convertToEcmaScriptString(String string) {
          int len = string.length();
          InternalStringBuilder buf = new InternalStringBuilder(len);
          for(int i = 0; i < len; i++) {
              char c = string.charAt(i);
              // skip the \\ and consume the next character either appending it or turning it back
              // into the single character that it should have been in the first place.
              
              // if slash and not at the last character...
              if(c == '\\' && i + 1 < len) {
                  i++;
  
                  // skip the slash
                  c = string.charAt(i);
  
                  if(c == 'b')
                      c = '\b';
                  else if(c == 't')
                      c = '\t';
                  else if(c == 'n')
                      c = '\n';
                  //else if(c == 'v') c = '\v';
                  else if(c == 'f')
                      c = '\f';
                  else if(c == 'r') c = '\r';
                  // @todo: unicode escaping?
              }
  
              buf.append(c);
          }
  
          LOGGER.trace("converted String to JavaScript compliant string: " + buf.toString());
  
          return buf.toString();
      }
docs: Given a Java String, this value needs to be converted into a JavaScript compliant String.
  See JavaScript: The Definitive Guide for how to do this