Replaces localized digits in $str with latin digits.

@param string $str
@return string Latinized string
774607
protected function latinizeDigits($str) {
		$result = '';
		$num = new \NumberFormatter($this->locale, \NumberFormatter::DECIMAL);
		preg_match_all('/.[\x80-\xBF]*/', $str, $matches);
		foreach ($matches[0] as $char) {
			$pos = 0;
			$parsedChar = $num->parse($char, \NumberFormatter::TYPE_INT32, $pos);
			$result .= $pos ? $parsedChar : $char;
		}
		return $result;
	}
1287562
public static function encodeOperators(
        $str)
    {
        if (self::$_translations === null) {
            self::_buildTranslations();
        }

        return strtr($str, self::$_translations['encode']);
    }
653734
static function convertStringToUnicode( $str )
    {
        $unicodeValues = array();
        $strLen = strlen( $str );
        for ( $offset = 0; $offset < $strLen; )
        {
            $charLen = 1;
            $unicodeValue = eZUTF8Codec::fromUTF8( $str, $offset, $charLen );
            if ( $unicodeValue !== false )
                $unicodeValues[] = $unicodeValue;
            $offset += $charLen;
        }
        return $unicodeValues;
    }
8185
public function str2unicode($str)
    {
        $uni = '';
        $str = (string) $str;
        for ($i = 0; $i < strlen($str); $i++) {
            $a = ord($str{$i}) << 8;
            $uni .= sprintf("%X", $a);
        }
        return pack('H*', $uni);
    }
288744
protected static function convertToLowercase($str)
    {
        $explodedStr = explode('_', $str);

        if (count($explodedStr) > 1) {
            $lowerCasedStr = [];
            foreach ($explodedStr as $value) {
                $lowerCasedStr[] = strtolower($value);
            }
            $str = implode('_', $lowerCasedStr);
        }

        return $str;
    }
915957
private function _do($str)
    {
        $str = (string) $str;
        $strInt = (int) $str;
        $strFloat = (float) $str;
        if (
            !$str
            ||
            (string) $strInt === $str
            ||
            (string) $strFloat === $str
        ) {

            // no xss found
            if ($this->_xss_found !== true) {
                $this->_xss_found = false;
            }

            return $str;
        }

        // remove the BOM from UTF-8 / UTF-16 / UTF-32 strings
        $str = UTF8::remove_bom($str);

        // replace the diamond question mark (�) and invalid-UTF8 chars
        $str = UTF8::replace_diamond_question_mark($str, '');

        // replace invisible characters with one single space
        $str = UTF8::remove_invisible_characters($str, true, ' ');

        // normalize the whitespace
        $str = UTF8::normalize_whitespace($str);

        // decode UTF-7 characters
        $str = $this->_repack_utf7($str);

        // decode the string
        $str = $this->_decode_string($str);

        // remove all >= 4-Byte chars if needed
        if ($this->_stripe_4byte_chars) {
            $str = (string) \preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $str);
        }

        // backup the string (for later comparision)
        $str_backup = $str;

        // remove strings that are never allowed
        $str = $this->_do_never_allowed($str);

        // corrects words before the browser will do it
        $str = $this->_compact_exploded_javascript($str);

        // remove disallowed javascript calls in links, images etc.
        $str = $this->_remove_disallowed_javascript($str);

        // remove evil attributes such as style, onclick and xmlns
        $str = $this->_remove_evil_attributes($str);

        // sanitize naughty JavaScript elements
        $str = $this->_sanitize_naughty_javascript($str);

        // sanitize naughty HTML elements
        $str = $this->_sanitize_naughty_html($str);

        // final clean up
        //
        // -> This adds a bit of extra precaution in case something got through the above filters.
        $str = $this->_do_never_allowed_afterwards($str);

        // check for xss
        if ($this->_xss_found !== true) {
            $this->_xss_found = !($str_backup === $str);
        }

        return $str;
    }
1202540
public static function encodeIRI( $str )
    {
        $codec = eZTextCodec::instance( false, 'utf-8' );
        $str = $codec->convertString( $str ); // Make sure the string is in utf-8
        $out = explode( "/", $str ); // Don't encode the slashes
        foreach ( $out as $i => $o )
        {
            if ( preg_match( "#^[\(]([a-zA-Z0-9_]+)[\)]#", $o, $m ) )
            {
                // Don't encode '(' and ')' in user parameters
                $out[$i] = '(' . urlencode( $m[1] ) . ')';
            }
            else
            {
                $out[$i] = urlencode( $o ); // Let PHP do the rest
            }
        }
        $tmp = join( "/", $out );
        // Don't encode '~' in URLs
        $tmp = str_replace( '%7E', '~', $tmp );
        return $tmp;
    }
994282
private static function utf8_to_unicode( &$str )
    {
        $unicode = array();
        $values = array();
        $looking_for = 1;

        for ($i = 0; $i < strlen( $str ); $i++ ) {
            $this_value = ord( $str[ $i ] );
            if ( $this_value < 128 ) $unicode[] = $this_value;
            else {
                if ( count( $values ) == 0 ) $looking_for = ( $this_value < 224 ) ? 2 : 3;
                $values[] = $this_value;
                if ( count( $values ) == $looking_for ) {
                    $number = ( $looking_for == 3 ) ?
                        ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ):
                        ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 );
                    $unicode[] = $number;
                    $values = array();
                    $looking_for = 1;
                }
            }
        }
        return $unicode;
    }
332267
private function unescapeLatinCharacters($str)
    {
        if ($this->latinCharacters) {
            $str = vsprintf($str, $this->latinCharacters);
            $this->latinCharacters = array();
        }

        return $str;
    }
199318
public static function encode(String $str) : String
    {
        return str_replace(array_keys(self::$phpTagChars), array_values(self::$phpTagChars), $str);
    }
885138
public static function nailDecode(String $str) : String
    {
        $str = str_replace(array_values(self::$nailChars), array_keys(self::$nailChars), $str);

        return $str;
    }
1165255
public static function toNumber($str)
    {
        if (is_string($str)) {
            $str = preg_replace("~[^0-9-.]~", "", $str);
        }
        return (strpos($str, ".") === false)
            ? intval($str)
            : floatval($str);
    }
635070
public static function decode(String $str) : String
    {
        return preg_replace
        (
            array_keys(self::$scriptTagCharsDecode), 
            array_values(self::$scriptTagCharsDecode), 
            $str
        );
    }
72984
public static function toString($str){
		$str = strtoupper($str);

		// csSave actually has to be able to consider extra characters
		if(self::$charset === Base32Characters::CROCKFORD){
			$str = str_replace('O', '0', $str);
			$str = str_replace(['I', 'L'], '1', $str);
		}

		return self::bin2str(self::toBin($str));
	}
843650
public static function toKey($str)
  {
    // Remove spaces and dashes, then convert to lower case.
    $str = self::toUnderscoreSeparated($str);
    $str = mb_strtolower($str);

    return $str;
  }
280830
public static function encodingWithUtf8($str)
    {
        $cur_encoding = mb_detect_encoding($str);
        if ($cur_encoding == "UTF-8" && mb_check_encoding($str, "UTF-8")) {
            return $str;
        } else {
            return utf8_encode($str);
        }
    }
1168183
public static function toSMS($str) {
        $str = str_replace(array(' ', 'é', 'è', 'ó', 'à', 'â', ',', '?', "'"), array('+', '%E9', '%E8', 'o', '%E0', '%E2', '%82', '%3F', "%27"), $str);

        return $str;
    }