src/net/mail/Mailer.php
protected function encodeNonAsciiChars($value) {
        if (is_array($value)) {
            /** @var string[] */
            $result = [];
            foreach ($value as $k => $v) {
                $result[$k] = $this->{__FUNCTION__}($v);
            }
            return $result;
        }

        if (preg_match('/[\x80-\xFF]/', $value)) {
            return '=?utf-8?B?'.base64_encode($value).'?=';
          //$value = '=?utf-8?Q?'.imap_8bit($value).'?=';       // requires imap extension and the encoded string is longer
        }
        return $value;

        // TODO: see https://tools.ietf.org/html/rfc1522
        //
        // An encoded-word may not be more than 75 characters long, including charset,
        // encoding, encoded-text, and delimiters.  If it is desirable to encode more
        // text than will fit in an encoded-word of 75 characters, multiple encoded-words
        // (separated by SPACE or newline) may be used.  Message header lines that contain
        // one or more encoded words should be no more than 76 characters long.
        //
        // While there is no limit to the length of a multiple-line header
        // field, each line of a header field that contains one or more
        // encoded-words is limited to 76 characters.
    }
protected function encodeNonAsciiChars($value) {
        if (is_array($value)) {
            /** @var string[] */
            $result = [];
            foreach ($value as $k => $v) {
                $result[$k] = $this->{__FUNCTION__}($v);
            }
            return $result;
        }

        if (preg_match('/[\x80-\xFF]/', $value)) {
            return '=?utf-8?B?'.base64_encode($value).'?=';
          //$value = '=?utf-8?Q?'.imap_8bit($value).'?=';       // requires imap extension and the encoded string is longer
        }
        return $value;

        // TODO: see https://tools.ietf.org/html/rfc1522
        //
        // An encoded-word may not be more than 75 characters long, including charset,
        // encoding, encoded-text, and delimiters.  If it is desirable to encode more
        // text than will fit in an encoded-word of 75 characters, multiple encoded-words
        // (separated by SPACE or newline) may be used.  Message header lines that contain
        // one or more encoded words should be no more than 76 characters long.
        //
        // While there is no limit to the length of a multiple-line header
        // field, each line of a header field that contains one or more
        // encoded-words is limited to 76 characters.
    }
protected function encodeNonAsciiChars ( $ value ) { if ( is_array ( $ value ) ) { /** @var string[] */ $ result = [ ] ; foreach ( $ value as $ k => $ v ) { $ result [ $ k ] = $ this -> { __FUNCTION__ } ( $ v ) ; } return $ result ; } if ( preg_match ( '/[\x80-\xFF]/' , $ value ) ) { return '=?utf-8?B?' . base64_encode ( $ value ) . '?=' ; //$value = '=?utf-8?Q?'.imap_8bit($value).'?=';       // requires imap extension and the encoded string is longer } return $ value ; // TODO: see https://tools.ietf.org/html/rfc1522 // // An encoded-word may not be more than 75 characters long, including charset, // encoding, encoded-text, and delimiters.  If it is desirable to encode more // text than will fit in an encoded-word of 75 characters, multiple encoded-words // (separated by SPACE or newline) may be used.  Message header lines that contain // one or more encoded words should be no more than 76 characters long. // // While there is no limit to the length of a multiple-line header // field, each line of a header field that contains one or more // encoded-words is limited to 76 characters. }
Encode non-ASCII characters with UTF-8. If a string doesn't contain non-ASCII characters it is not modified.

@param  string|string[] $value - a single or a list of values

@return string|string[] - a single or a list of encoded values
Encode non - ASCII characters with UTF - 8 . If a string doesn t contain non - ASCII characters it is not modified .