Remove macrons from the specified string.

Based on Wordpress remove_accents().

@param string $str The input string.

@return string Cleaned string.
514188
public static function removeMacrons($str)
    {
        if ( !preg_match('/[\x80-\xff]/', $str) ) {
            return $str;
        }

        $chars = array(
            // Some romanization system may use circumflex accent rather than macron
            chr(195).chr(130) => 'A', chr(195).chr(162) => 'a',
            chr(195).chr(142) => 'I', chr(195).chr(174) => 'i',
            chr(195).chr(155) => 'U', chr(195).chr(187) => 'u',
            chr(195).chr(138) => 'E', chr(195).chr(170) => 'e',
            chr(195).chr(148) => 'O', chr(195).chr(180) => 'o',
            // Macrons
            chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
            chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
            chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
            chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
            chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
        );

        return strtr($str, $chars);
    }
953375
protected function stripWhitespaces($str) {
       switch($this->stripWhitespaceMode) {
           case self::STRIP_WHITESPACE_AUTO:
               if(Helper::countSubString($str, '　') > self::STRIP_WHITESPACE_AUTO_NB_SPACES) {
                   break;
               }
           case self::STRIP_WHITESPACE_ALL:
               $str = preg_replace('/\x{3000}|\s/u', '', $str);
               break;
       }

       return $str;
    }
979075
protected function _removeBlobWhenNonempty(&$str)
    {
        if ($str &&
            ($str[0] === '[') &&
            (($i = $this->_removeBlob($str, 0)) !== false) &&
            ($i !== strlen($str))) {
            $str = substr($str, $i);
            return true;
        }

        return false;
    }
498347
protected static function filterAttributes($str)
    {
        $out = '';
        if (preg_match_all('#\s*[a-z\-]+\s*=\s*(\042|\047)([^\\1]*?)\\1#is', $str, $matches)) {
            foreach ($matches[ 0 ] as $match) {
                $out .= preg_replace('#/\*.*?\*/#s', '', $match);
            }
        }

        return $out;
    }
276133
public static function stripAll($str)
    {
        $str = stripslashes($str);
        $str = strip_tags($str);
        $str = \sb\Strings::unicodeUrldecode($str);
        $str = self::stripBling($str);
        $str = \sb\Strings::stripMicrosoftChars($str);
        return $str;
    }
1218463
public function unescapeMd($str)
    {
        if (strpos ($str,'\\') === false) return $str;
        return preg_replace(self::UNESCAPE_MD_RE, '$1', $str);
    }
1369771
protected function transliterateChoonpu($str, $macrons)
    {
        $keys = array_keys($macrons);
        $pattern = '/([' . implode('', $keys) . '])ー/u';

        return preg_replace_callback($pattern, function($matches) use ($macrons) {
            return $macrons[$matches[1]];
        }, $str);
    }
1303472
protected function sanitizeComponent($str)
    {
        if (is_null($str)) {
            return $str;
        }
        $str = filter_var((string) $str, FILTER_UNSAFE_RAW, array('flags' => FILTER_FLAG_STRIP_LOW));
        $str = trim($str);

        return $str;
    }
767707
public static function trim_utf8_bom($str) {
        $bom = "\xef\xbb\xbf";
        if (strpos($str, $bom) === 0) {
            return substr($str, strlen($bom));
        }
        return $str;
    }
1281525
public static function removeAccents($str) {
        $str = str_replace(' & ', ' ', $str);
        $str = htmlentities($str);
        $str = preg_replace('#&([A-Za-z])(?:acute|grave|cedil|circ|orn|ring|slash|th|tilde|uml);#', '\1', $str);
        $str = preg_replace('#&([A-Za-z]{2})(?:lig);#', '\1', $str);
        // Supprimer tout le reste
        $str = preg_replace('#&[^;]+;#', '', $str);
        return $str;
    }
626141
public static function normalize($str)
    {
        $str = strtr($str, ['ő' => 'o', 'ű' => 'u', 'Ő' => 'O', 'Ű' => 'U']);
        $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖŐØÙÚÛÜŰÝÞßàáâãäåæçèéêëìíîïðñòóôõöőøùúûűüýýþÿŔŕ';
        $b = 'AAAAAAACEEEEIIIIDNOOOOOOOUUUUUYbsaaaaaaaceeeeiiiidnooooooouuuuuyybyRr';
        $str = utf8_decode($str);
        $str = str_replace('?', '', $str);
        $str = strtr($str, utf8_decode($a), $b);
        return utf8_encode($str);
    }
1195635
public static function trimSpaceInStr($str)
    {
        $pat = array(" ", "　", "\t", "\n", "\r");
        $string = array("", "", "", "", "", );
        return str_replace($pat, $string, $str);
    }
352850
public static function cleanTextarea($str)
  {
    $str = str_replace('&nbsp;', ' ', $str);
    $str = preg_replace("/[\r\n]{2,}/", "\n\n", $str);
    $str = preg_replace("/<br([^>]*)>/", "\n", $str);
    
    if ( !preg_match("/<(p|table|figure|div|h[1-6])>.+<\/$1>/", $str) ){
      $str = '<p>'.$str.'</p>';
    }
    $str = preg_replace("/\n\n/", "</p> <p>", $str);
    $str = trim($str);
    $str = preg_replace("/<p>\s*<\/p>/", "", $str);
    $str = preg_replace("/\n/", "<br />", $str);
    $str = trim($str);
    
    return $str;
  }
1230081
public static function getClean($str)
    {
        if (is_object($str) && get_class($str) == 'Xiphe\HTML\core\Tag') {
            $Tag = $str;
            $str = $Tag->content;
        }
        switch (Config::get('cleanMode')) {
        case 'strong':
            $str = self::getStrong($str);
            break;
        case 'basic':
            $str = self::getBasic($str);
            break;
        default:
            return $str;
        }
        if (isset($Tag)) {
            $Tag->content = $str;
        }

        return $str;
    }
1193570
public static function removeAccents($str)
	{
		// $from_chars = explode(',', 'À,Á,Â,Ã,Ä,Å,Ç,È,É,Ê,Ë,Ì,Í,Î,Ï,Ð,Ñ,Ò,Ó,Ô,Õ,Ö,Ø,Ǿ,Ù,Ú,Û,Ü,Ý,ß,à,á,â,ã,ä,å,ç,è,é,ê,ë,ì,í,î,ï,ð,ñ,ò,ó,ô,õ,ö,ø,ǿ,ù,ú,û,ü,ý,ÿ');
		// $to_chars	= str_split('AAAAAACEEEEIIIIDNOOOOOOOUUUUYBaaaaaaceeeeiiiionooooooouuuuyy');
		// $str = str_replace($from_chars, $to_chars, $str);
        $map = array(
			// single letters
            'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'ą' => 'a', 'å' => 'a', 'ā' => 'a', 'ă' => 'a', 'ǎ' => 'a', 'ǻ' => 'a',
            'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Ą' => 'A', 'Å' => 'A', 'Ā' => 'A', 'Ă' => 'A', 'Ǎ' => 'A', 'Ǻ' => 'A',
			'ß' => 'B',
			'ç' => 'c', 'ć' => 'c', 'ĉ' => 'c', 'ċ' => 'c', 'č' => 'c',
			'Ç' => 'C', 'Ć' => 'C', 'Ĉ' => 'C', 'Ċ' => 'C', 'Č' => 'C',
			'ď' => 'd', 'đ' => 'd',
			'Ð' => 'D', 'Ď' => 'D', 'Đ' => 'D',
			'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ę' => 'e', 'ē' => 'e', 'ĕ' => 'e', 'ė' => 'e', 'ě' => 'e',
			'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ę' => 'E', 'Ē' => 'E', 'Ĕ' => 'E', 'Ė' => 'E', 'Ě' => 'E',
			'ƒ' => 'f',
			'ĝ' => 'g', 'ğ' => 'g', 'ġ' => 'g', 'ģ' => 'g',
			'Ĝ' => 'G', 'Ğ' => 'G', 'Ġ' => 'G', 'Ģ' => 'G',
			'ĥ' => 'h', 'ħ' => 'h', 'Ĥ' => 'H', 'Ħ' => 'H',
			'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i',
			'ĩ' => 'i', 'ī' => 'i', 'ĭ' => 'i', 'į' => 'i', 'ſ' => 'i', 'ǐ' => 'i', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ĩ' => 'I', 'Ī' => 'I', 'Ĭ' => 'I', 'Į' => 'I', 'İ' => 'I', 'Ǐ' => 'I',
			'ĵ' => 'j', 'Ĵ' => 'J',
			'ķ' => 'k', 'Ķ' => 'K',
			'ł' => 'l', 'ĺ' => 'l', 'ļ' => 'l', 'ľ' => 'l', 'ŀ' => 'l',
			'Ł' => 'L', 'Ĺ' => 'L', 'Ļ' => 'L', 'Ľ' => 'L', 'Ŀ' => 'L',
			'ñ' => 'n', 'ń' => 'n', 'ņ' => 'n', 'ň' => 'n', 'ŉ' => 'n',
			'Ñ' => 'N', 'Ń' => 'N', 'Ņ' => 'N', 'Ň' => 'N',
			'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ð' => 'o', 'ø' => 'o', 'ō' => 'o', 'ŏ' => 'o', 'ő' => 'o', 'ơ' => 'o', 'ǒ' => 'o', 'ǿ' => 'o',
			'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ō' => 'O', 'Ŏ' => 'O', 'Ő' => 'O', 'Ơ' => 'O', 'Ǒ' => 'O', 'Ǿ' => 'O',
			'ŕ' => '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', 'ǖ' => 'u', 'ǘ' => 'u', 'ǚ' => 'u', 'ǜ' => 'u',
			'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ũ' => 'U', 'Ū' => 'U', 'Ŭ' => 'U', 'Ů' => 'U', 'Ű' => 'U', 'Ų' => 'U', 'Ư' => 'U', 'Ǔ' => 'U', 'Ǖ' => 'U', 'Ǘ' => 'U', 'Ǚ' => 'U', 'Ǜ' => 'U',
			'ŵ' => 'w',
			'Ŵ' => 'W',
			'ý' => 'y', 'ÿ' => 'y', 'ŷ' => 'y',
			'Ý' => 'Y', 'Ÿ' => 'Y', 'Ŷ' => 'Y',
			'ż' => 'z', 'ź' => 'z', 'ž' => 'z',
			'Ż' => 'Z', 'Ź' => 'Z', 'Ž' => 'Z',
			// accentuated ligatures
			'Ǽ' => 'A',
			'ǽ' => 'a',
        );
		$str = self::toUtf8($str);
        $str = \strtr($str, $map);
		return $str;
	}
332267
private function unescapeLatinCharacters($str)
    {
        if ($this->latinCharacters) {
            $str = vsprintf($str, $this->latinCharacters);
            $this->latinCharacters = array();
        }

        return $str;
    }
1269482
public static function toSlugUnderscoreUppercase(string $str)
  {
    $clean = implode(' ', self::splitCamelCase($str));
    $clean = self::toSlug($clean);
    $clean = self::toUnderscoreSeparated($clean);
    $clean = strtoupper($clean);
    return $clean;
  }