Maps chars to URI escaped equivalents: "\n" -> "%0a".
@private
195138
function escapeCssUrlChar(ch) {
    return cssUrlChars[ch]
        || (cssUrlChars[ch] = (ch < '\x10' ? '%0' : '%')
            + ch.charCodeAt(0).toString(16));
  }
776433
function decode(str, keep_slashes) {
                        isEncoded && (str = str.replace(/\uFEFF[0-9]/g, function(str) {
                            return encodingLookup[str];
                        }));
                        keep_slashes || (str = str.replace(/\\([\'\";:])/g, '$1'));
                        return str;
                    }
819794
function escape(srcStr) {
      forEach(deCodes, function (str, idx) {
        srcStr = srcStr.replace(new RegExp(str, 'g'), enCodes[idx]);
      });
      return srcStr;
    }
585082
def write_json_escape_char(ch)
      trans.write('\\u')
      ch_value = ch[0]
      if (ch_value.kind_of? String)
        ch_value = ch.bytes.first
      end
      trans.write(ch_value.to_s(16).rjust(4,'0'))
    end
564033
function escape (string) {
  return string
    .replace(/ /g, '\\ ')
    .replace(/\n/g, '')
    .replace(/\(/g, '\\(')
    .replace(/\)/g, '\\)');
}
863046
function escapeValue(value) {
        switch (options.type) {
        case 'js':
            return value.replace(/'/g, '\\\'');
        case 'json':
            return value.replace(/"/g, '\\"');
        default:
            return value;
        }
    }
701194
function urlEncodeIfNecessary(s) {
		var regex = /[\\\"<>\.;]/;
		var hasBadChars = regex.exec(s) != null;
		return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
	}
625106
function _convertUnicode(originalStr) {
  let m;
  let c;
  let cStr;
  let lastI = 0;

  // Matches \u#### but not \\u####
  const unicodeRegex = /\\u[0-9a-fA-F]{4}/g;

  let convertedStr = '';
  while ((m = unicodeRegex.exec(originalStr))) {
    // Don't convert if the backslash itself is escaped
    if (originalStr[m.index - 1] === '\\') {
      continue;
    }

    try {
      cStr = m[0].slice(2); // Trim off start
      c = String.fromCharCode(parseInt(cStr, 16));
      if (c === '"') {
        // Escape it if it's double quotes
        c = `\\${c}`;
      }

      // + 1 to account for first matched (non-backslash) character
      convertedStr += originalStr.slice(lastI, m.index) + c;
      lastI = m.index + m[0].length;
    } catch (err) {
      // Some reason we couldn't convert a char. Should never actually happen
      console.warn('Failed to convert unicode char', m[0], err);
    }
  }

  // Finally, add the rest of the string to the end.
  convertedStr += originalStr.slice(lastI, originalStr.length);

  return convertedStr;
}
105750
private static String normalizeUriEscape(byte []rawUri, int i, int len,
                                           String encoding)
    throws IOException
  {
    ByteToChar converter = allocateConverter();
    // XXX: make this configurable

    if (encoding == null) {
      encoding = "utf-8";
    }

    try {
      converter.setEncoding(encoding);
    } catch (UnsupportedEncodingException e) {
      log.log(Level.FINE, e.toString(), e);
    }

    try {
      while (i < len) {
        int ch = rawUri[i++] & 0xff;

        if (ch == '%')
          i = scanUriEscape(converter, rawUri, i, len);
        else
          converter.addByte(ch);
      }

      String result = converter.getConvertedString();
      
      freeConverter(converter);
      
      return result;
    } catch (Exception e) {
      throw new BadRequestException(L.l("The URL contains escaped bytes unsupported by the {0} encoding.", encoding));
    }
  }
293415
function encodeUriSegment(s) {
    return encodeUriString(s).replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/%26/gi, '&');
}
411112
def convert_reserved_characters(string)
    string.gsub!(/&quot;/, '\"')
    string.gsub!(/&apos;/, '\'')
    string.gsub!(/&amp;/,  '\&')
    string.gsub!(/&lt;/,   '\<')
    string.gsub!(/&lt;/,   '\>')
    string
  end
653125
function escapeString(string) {
  var result = '';
  var char;
  var escapeSeq;

  for (var i = 0; i < string.length; i++) {
    char = string.charCodeAt(i);
    escapeSeq = ESCAPE_SEQUENCES[char];
    result += !escapeSeq && isPrintable(char)
      ? string[i]
      : escapeSeq || encodeHex(char);
  }

  return result;
}
87389
function escapeHtmlChars(text) 
{
    let ast = myna.parsers.html_reserved_chars(text);
    if (!ast.children)    
        return "";
    return ast.children.map(astNodeToHtmlText).join('');
}
921929
function () {
                    var str, j = i, e, index = i;

                    if (input.charAt(j) === '~') { j++; e = true; } // Escaped strings
                    if (input.charAt(j) !== '"' && input.charAt(j) !== "'") { return; }

                    if (e) { $char('~'); }

                    str = $re(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/);
                    if (str) {
                        return new(tree.Quoted)(str[0], str[1] || str[2], e, index, env.currentFileInfo);
                    }
                }
669727
function escapeCharacters(text, charsToEscape, afterBackslash) {

        var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g,"\\$1") + "])";

        if(afterBackslash) {
            regexString = "\\\\" + regexString;
        }

        var regex = new RegExp(regexString,"g");

        text = text.replace(regex,escapeCharacters_callback);

        return text;
    }
991706
static String normalizeUri(String s) {
    int n = s.length();
    boolean colonsIrrelevant = false;
    for (int i = 0; i < n; ++i) {
      char ch = s.charAt(i);
      switch (ch) {
        case '/': case '#': case '?': case ':':
          colonsIrrelevant = true;
          break;
        case '(': case ')':
        case '{': case '}':
          return normalizeUriFrom(s, i, colonsIrrelevant);
        case '\u0589':
        case '\u05c3':
        case '\u2236':
        case '\uff1a':
          if (!colonsIrrelevant) {
            return normalizeUriFrom(s, i, false);
          }
          break;
        default:
          if (ch <= 0x20) {
            return normalizeUriFrom(s, i, false);
          }
          break;
      }
    }
    return s;
  }
755390
function normalize(path) {
  var last = path.length - 1
  var lastC = path.charCodeAt(last)

  // If the uri ends with `#`, just return it without '#'
  if (lastC === 35 /* "#" */) {
    return path.substring(0, last)
  }

  return (path.substring(last - 2) === ".js" ||
      path.indexOf("?") > 0 ||
      lastC === 47 /* "/" */) ? path : path + ".js"
}