Transliterate Danish chars

@param string $s
@return string
496597
private function _transliterateDanish ($s)
    {
        $table = array(
        'æ' => 'ae', 
        'ø' => 'oe', 
        'å' => 'aa', 
        'Æ' => 'Ae', 
        'Ø' => 'Oe', 
        'Å' => 'Aa' 
        );
        return strtr($s, $table);
    }
41950
public static function possessive($sString)
    {
        //  Attempt to match the case
        $sLastChar       = substr($sString, -1);
        $bIsLowerCase    = strtolower($sLastChar) === $sLastChar;
        $sPossessionChar = $bIsLowerCase ? 's' : 'S';

        return substr($sString, -1) == $sPossessionChar ? $sString . '\'' : $sString . '\'' . $sPossessionChar;
    }
1037452
private static function unicodeChar($dec)
    {
        if ($dec < 0x80) {
            return chr($dec);
        }

        if ($dec < 0x0800) {
            return chr(0xC0 + ($dec >> 6))
                .chr(0x80 + ($dec & 0x3f));
        }

        if ($dec < 0x010000) {
            return chr(0xE0 + ($dec >> 12))
                    .chr(0x80 + (($dec >> 6) & 0x3f))
                    .chr(0x80 + ($dec & 0x3f));
        }

        if ($dec < 0x200000) {
            return chr(0xF0 + ($dec >> 18))
                    .chr(0x80 + (($dec >> 12) & 0x3f))
                    .chr(0x80 + (($dec >> 6) & 0x3f))
                    .chr(0x80 + ($dec & 0x3f));
        }
    }
681393
public static function strict($s)
	{
		if (! ReflectionTypeHint::isValid()) return false;
		if (is_null($s)) return $s;
		return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]+/sSX', '', $s);
	}
422739
public function addslashes($s) {
        // do not use php addslashes() because it depends on PHP quote settings!
        $s = str_replace('\\','\\\\',$s);
        $s = str_replace("\0","\\\0", $s);
        $s = str_replace("'",  "\\'", $s);
        return $s;
    }
389472
function unichr($dec) {
    if ($dec < 128) {
      $utf = chr($dec);
    } else if ($dec < 2048) {
      $utf = chr(192 + (($dec - ($dec % 64)) / 64));
      $utf .= chr(128 + ($dec % 64));
    } else {
      $utf = chr(224 + (($dec - ($dec % 4096)) / 4096));
      $utf .= chr(128 + ((($dec % 4096) - ($dec % 64)) / 64));
      $utf .= chr(128 + ($dec % 64));
    }
    return $utf;
  }
1162196
private static function needsNormalization($s)
    {
        $j = strlen($s) - 1;

        for ($k = 0; $k <= $j; $k++) {
            if (substr($s, $k, 1) !== '/') break;
        }

        $flag = ($k > 1) ? false : true;
        $i = 0;
        while ($k <= $j) {
            $c = substr($s, $k, 1);
            $c2 = substr($s, $k + 1, 1);
            $c3 = substr($s, $k + 2, 1);

            if ($c === '.' && ($k == $j || $c2 === '/' || $c2 === '.' && ($k + 1 == $j || $c3 === '/'))
            ) {
                $flag = false;
            }
            $i++;
            do {
                if ($k > $j) {
                    continue 2;
                }
            } while (substr($s, $k++, 1) !== '/');
            while ($k <= $j && substr($s, $k, 1) === '/') {
                $flag = false;
                $k++;
            }
        }

        return $flag ? false : $i;
    }
759959
public function transliterate($string)
	{
		if ($this->transliterator !== null)
		{
			return call_user_func($this->transliterator, $string);
		}

		$string = Latin::toAscii($string);
		$string = strtolower($string);

		return $string;
	}
223455
public function decode_uhex($s)
	{
		preg_match_all('/\\\u([0-9a-f]{4})/i', $s, $matches);
		$matches = $matches[count($matches) - 1];
		$map = array();

		foreach ($matches as $match)
		{
			if (!isset($map[$match]))
			{
				$map['\u' . $match] = html_entity_decode('&#' . hexdec($match) . ';', ENT_NOQUOTES, 'UTF-8');
			}
		}

		return str_replace(array_keys($map), $map, $s);
	}
1373016
public static function toAscii(string $str): string
    {
        try {
            $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
        } catch (\Exception $e) {
            $clean = false;
        }

        if ($clean === false) {
            $a = ['À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', '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', 'ǽ', 'Ǿ', 'ǿ'];
            $b = ['A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o'];
            $clean = str_replace($a, $b, $str);
        }

        $clean = preg_replace("/[^a-zA-Z0-9\_\|\ \-\.]/", '', $clean);
        $clean = strtolower(trim($clean, '-'));
        $clean = preg_replace("/[\/\_\|\ \-]+/", '-', $clean);

        return $clean;
    }
665687
public static function base64UrlSafeDecode($s)
    {
        $s = str_replace('_', '/', $s);
        $s = str_replace('-', '+', $s);
        $s = base64_decode($s);
        return ($s);
    }
583160
function phpEscape(s) {
  var result = '"';
  for (let cp of UnicodeUtils.getCodePoints(s)) {
    let special = specialEscape[cp];
    if (special !== undefined) {
      result += special;
    } else if (cp >= 0x20 && cp <= 0x7e) {
      result += String.fromCodePoint(cp);
    } else if (cp <= 0xFFFF) {
      result += '\\u{' + zeroPaddedHex(cp, 4) + '}';
    } else {
      result += '\\u{' + zeroPaddedHex(cp, 6) + '}';
    }
  }
  result += '"';
  return result;
}
1186481
public function transliterate($str) {

      $str = self::preTransliterate($str);

      // Workflow:
      //  1/ Default characters
      //  2/ Sokuon
      //  3/ Choonpu

      $str = self::transliterateDefaultCharacters($str, $this->mapping);

      $str = self::transliterateSokuon($str);

      $str = self::transliterateChoonpu($str, $this->macrons);

      return self::postTransliterate($str);
    }
39096
public String getLangDesc(String s) {
    if (s.equals("en"))
      return "English";
    if (s.equals("nl"))
      return "Nederlands (Dutch)";
    if (s.equals("de"))
      return "Deutsch (German)";
    if (s.equals("ru"))
      return "\u0440\u0443\u0301\u0441\u0441\u043a\u0438\u0439 (Russian)";
    return "\"" + s + "\"";
  }
518853
public static function reverse(string $s): string
    {
        if (\function_exists('\iconv')) {
            return \iconv('UTF-32LE', 'UTF-8', \strrev(\iconv('UTF-8', 'UTF-32BE', $s)));
        }

        \preg_match_all('/./us', $s, $ar);

        return \implode('', \array_reverse($ar[0]));
    }
695406
public static function convertCharacterEntitiesToASCII($string, $charset)
    {
        $matches = array();

        if (preg_match_all("/<(.+?)>/si", $string, $matches)) {

            $count = count($matches['0']);

            for ($i = 0; $i < $count; $i++) {
                $string = str_replace(
                    $matches['1'][$i],
                    html_entity_decode($matches['1'][$i], ENT_COMPAT, $charset),
                    $string
                );
            }
        }

        return $string;
    }
502923
private function transliterateHungarian($s)
    {
        $table = array(
            'á' => 'a',
            'é' => 'e',
            'í' => 'i',
            'ó' => 'o',
            'ö' => 'o',
            'ő' => 'o',
            'ú' => 'u',
            'ü' => 'u',
            'ű' => 'u',
        );
        return strtr($s, $table);
    }