Escapes a CSS identifier.
<p>
See https://drafts.csswg.org/cssom/#serialize-an-identifier.
</p>

@param identifier the identifier to escape
@return the escaped identifier
@since 6.4.7
@since 7.1.4
@since 7.4M1
548894
public String css(String identifier)
    {
        try {
            return new CSSIdentifierSerializer().serialize(identifier);
        } catch (IllegalArgumentException e) {
            LOGGER.warn("Failed to escape CSS identifier. {}", e.getMessage());
            return null;
        }
    }
988962
private static int getIndex(String identifier, String subIdentifier) {
		int position = identifier.indexOf(subIdentifier);
		if (position > 0) {
			String temp = identifier.substring(position + (subIdentifier.length()));
			return readInteger(temp);
		}
		return -1;
	}
472636
public static String escape(String raw) {
        checkNotNull(raw, "raw");
        String escaped = raw;
        escaped = escaped.replaceAll(UNESCAPED_WILDCARD_REGEX, WILDCARD_ESCAPE);
        escaped = escapeSeparators(escaped);
        return escaped;
    }
844688
private static IdentifierHandler<? extends Identifier> getExtendedIdentifierHandlerFor(Element element) {
		if (!checkExtendedIdentityElement(element)) {
			return null;
		}

		String name = element.getAttribute(IfmapStrings.IDENTITY_ATTR_NAME);

		Document extendedDocument;
		try {
			extendedDocument = DomHelpers.parseEscapedXmlString(name);
		} catch (UnmarshalException e) {
			return null;
		}
		Element extendedElement = extendedDocument.getDocumentElement();
		String nodeName = extendedElement.getLocalName();

		// try to find the most specific handler
		for (Entry<Class<? extends Identifier>, IdentifierHandler<? extends Identifier>> entry : sIdentifierHandlers
				.entrySet()) {

			String simpleClassName = entry.getKey().getSimpleName();

			if (simpleClassName.equalsIgnoreCase(nodeName)) {
				return entry.getValue();
			}
		}

		return null;
	}
596814
public static function stringify_identifier($identifier)
	{
		// Identifier may not be empty, but can be false or 0
		if ($identifier === '' || $identifier === null)
		{
			throw new \FuelException('The identifier cannot be empty, must contain a value of any kind other than null or an empty string.');
		}

		// In case of string or int just return it as a string
		if (is_string($identifier) || is_int($identifier))
		{
			// cleanup to only allow alphanum chars, dashes, dots & underscores
			if (preg_match('/^([a-z0-9_\.\-]*)$/iuD', $identifier) === 0)
			{
				throw new \FuelException('Cache identifier can only contain alphanumeric characters, underscores, dashes & dots.');
			}

			return (string) $identifier;
		}
		// In case of array, bool or object return the md5 of the $identifier's serialization
		else
		{
			return '_hashes.'.md5(serialize($identifier));
		}
	}
381384
public static String quote(String identifier) {
        if (StringUtils.isEmpty(identifier)) {
            return identifier;
        }

        String res = identifier.trim();

        if (!res.startsWith("\"")) {
            res = "\"" + res;
        }

        if (!res.endsWith("\"")) {
            res = res + "\"";
        }

        return res;

    }
983176
protected function _stringToSemKey($identifier)
    {
        $md5 = md5($identifier);
        $key = 0;
        for ($i = 0; $i < 32; $i++) {
            $key += ord($md5{$i}) * $i;
        }
        return $key;
    }
774593
def _escape_identifiers(self, item):
        
        if self._escape_char == '':
            return item

        for field in self._reserved_identifiers:
            if item.find('.%s' % field) != -1:
                _str = "%s%s" % (self._escape_char, item.replace('.', '%s.' % self._escape_char))
                # remove duplicates if the user already included the escape
                return re.sub(r'[%s]+'%self._escape_char, self._escape_char, _str)

        if item.find('.') != -1:
            _str = "%s%s%s" % (self._escape_char, item.replace('.', '%s.%s'%(self._escape_char, self._escape_char)),
            self._escape_char)
        else:
            _str = self._escape_char+item+self._escape_char
        # remove duplicates if the user already included the escape
        return re.sub(r'[%s]+'%self._escape_char, self._escape_char, _str)
327594
private function resolveIcon(string $identifier): string
    {
        $config = null;

        $parameterName = $this->getConfigParameterName($identifier);
        if ($this->configResolver->hasParameter($parameterName)) {
            $config = $this->configResolver->getParameter($parameterName);
        }

        if ($config === null || empty($config[self::ICON_KEY])) {
            $config = $this->configResolver->getParameter(
                $this->getConfigParameterName(self::DEFAULT_IDENTIFIER)
            );
        }

        return $config[self::ICON_KEY];
    }
60659
private static boolean isValidIdentifier(String identifier) {
    if (identifier.isEmpty()) {
      return false;
    }

    char first = identifier.charAt(0);
    if (first != '_' && (first < 'a' || first > 'z') && (first < 'A' || first > 'Z')) {
      return false;
    }
    for (int i = 1; i < identifier.length(); i++) {
      char c = identifier.charAt(i);
      if (c != '_' && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9')) {
        return false;
      }
    }
    return true;
  }
398852
final public void Identifier() throws ParseException {
                                 /*@bgen(jjtree) Identifier */
                                  AstIdentifier jjtn000 = new AstIdentifier(JJTIDENTIFIER);
                                  boolean jjtc000 = true;
                                  jjtree.openNodeScope(jjtn000);Token t = null;
    try {
      t = jj_consume_token(IDENTIFIER);
                     jjtree.closeNodeScope(jjtn000, true);
                     jjtc000 = false;
                     jjtn000.setImage(t.image);
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
      }
    }
  }
871711
public function escape($identifier): string {
        if ($identifier instanceof Literal) {
            return $identifier->getValue($this);
        }
        return '`'.str_replace('`', '``', $identifier).'`';
    }
595536
private boolean exclude(String identifier) {
    String excludeMatch = null;
    for (String rule = identifier; rule != null; rule = enclosing(rule)) {
      if (excludes.contains(rule)) {
        excludeMatch = rule;
      }
    }
    if (excludeMatch != null) {
      usedExcludes.add(excludeMatch);
      return true;
    }
    return false;
  }
331552
private static int escape(char[] cc, char c, int index) {
        cc[index++] = '%';
        cc[index++] = Character.forDigit((c >> 4) & 0xF, 16);
        cc[index++] = Character.forDigit(c & 0xF, 16);
        return index;
    }
190730
public static final String escapeString(final String delimiter,
            final String input) {
        final String escaped = escapeString(input);
        if (escaped.isEmpty()) {
            return escaped;
        }
        return delimiter + escaped;
    }
1100544
@Override
    public Object get(final String identifier) {
        Declaration decl = getDeclarations().get( identifier );
        if ( decl == null ) {
            throw new IllegalArgumentException( "identifier '" + identifier + "' cannot be found" );
        }
        return get( decl );
    }
173237
public static String escapeHtml(String s)
  {
    if (s == null)
      return null;

    StringBuilder cb = new StringBuilder();
    int lineCharacter = 0;
    boolean startsWithSpace = false;
    
    for (int i = 0; i < s.length(); i++) {
      char ch = s.charAt(i);

      lineCharacter++;
      
      if (ch == '<')
        cb.append("&lt;");
      else if (ch == '&')
        cb.append("&amp;");
      else if (ch == '\n' || ch == '\r') {
        lineCharacter = 0;
        cb.append(ch);
        startsWithSpace = false;
      }
      else if (lineCharacter > 70 && ch == ' ' && ! startsWithSpace) {
        lineCharacter = 0;
        cb.append('\n');
        for (; i + 1 < s.length() && s.charAt(i + 1) == ' '; i++) {
        }
      }
      else if (lineCharacter == 1 && (ch == ' ' || ch == '\t')) {
        cb.append((char) ch);
        startsWithSpace = true;
      }
      else
        cb.append(ch);
    }

    return cb.toString();
  }