src/Encoder/StringEncoder.php
private function encodeUtf8($string, $options)
    {
        $pattern =
            '/  [\xC2-\xDF][\x80-\xBF]
              |  \xE0[\xA0-\xBF][\x80-\xBF]
              | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
              |  \xED[\x80-\x9F][\x80-\xBF]
              |  \xF0[\x90-\xBF][\x80-\xBF]{2}
              | [\xF1-\xF3][\x80-\xBF]{3}
              |  \xF4[\x80-\x8F][\x80-\xBF]{2}/x';

        return preg_replace_callback($pattern, function ($match) use ($options) {
            return sprintf($options['hex.capitalize'] ? '\u{%X}' : '\u{%x}', $this->getCodePoint($match[0]));
        }, $string);
    }
private function encodeUtf8($string, $options)
    {
        $pattern =
            '/  [\xC2-\xDF][\x80-\xBF]
              |  \xE0[\xA0-\xBF][\x80-\xBF]
              | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
              |  \xED[\x80-\x9F][\x80-\xBF]
              |  \xF0[\x90-\xBF][\x80-\xBF]{2}
              | [\xF1-\xF3][\x80-\xBF]{3}
              |  \xF4[\x80-\x8F][\x80-\xBF]{2}/x';

        return preg_replace_callback($pattern, function ($match) use ($options) {
            return sprintf($options['hex.capitalize'] ? '\u{%X}' : '\u{%x}', $this->getCodePoint($match[0]));
        }, $string);
    }
private function encodeUtf8 ( $ string , $ options ) { $ pattern = '/  [\xC2-\xDF][\x80-\xBF]
              |  \xE0[\xA0-\xBF][\x80-\xBF]
              | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
              |  \xED[\x80-\x9F][\x80-\xBF]
              |  \xF0[\x90-\xBF][\x80-\xBF]{2}
              | [\xF1-\xF3][\x80-\xBF]{3}
              |  \xF4[\x80-\x8F][\x80-\xBF]{2}/x' ; return preg_replace_callback ( $ pattern , function ( $ match ) use ( $ options ) { return sprintf ( $ options [ 'hex.capitalize' ] ? '\u{%X}' : '\u{%x}' , $ this -> getCodePoint ( $ match [ 0 ] ) ) ; } , $ string ) ; }
Encodes all multibyte UTF-8 characters into PHP7 string encoding.
@param string $string The string to encoder
@param array $options The string encoding options
@return string The string with all the multibyte characters encoded
Encodes all multibyte UTF - 8 characters into PHP7 string encoding .