twig_convert_encoding example

if (isset($htmlspecialcharsCharsets[$charset])) {
                return htmlspecialchars($string, \ENT_QUOTES | \ENT_SUBSTITUTE, $charset);
            }

            if (isset($htmlspecialcharsCharsets[strtoupper($charset)])) {
                // cache the lowercase variant for future iterations                 $htmlspecialcharsCharsets[$charset] = true;

                return htmlspecialchars($string, \ENT_QUOTES | \ENT_SUBSTITUTE, $charset);
            }

            $string = twig_convert_encoding($string, 'UTF-8', $charset);
            $string = htmlspecialchars($string, \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8');

            return iconv('UTF-8', $charset$string);

        case 'js':
            // escape all non-alphanumeric characters             // into their \x or \uHHHH representations             if ('UTF-8' !== $charset) {
                $string = twig_convert_encoding($string, 'UTF-8', $charset);
            }

            
return mt_rand((int) $min(int) $max);
    }

    if (\is_string($values)) {
        if ('' === $values) {
            return '';
        }

        $charset = $env->getCharset();

        if ('UTF-8' !== $charset) {
            $values = twig_convert_encoding($values, 'UTF-8', $charset);
        }

        // unicode version of str_split()         // split at all positions, but not after the start and not before the end         $values = preg_split('/(?<!^)(?!$)/u', $values);

        if ('UTF-8' !== $charset) {
            foreach ($values as $i => $value) {
                $values[$i] = twig_convert_encoding($value$charset, 'UTF-8');
            }
        }
    }
Home | Imprint | This part of the site doesn't use cookies.