system/libraries/Email.php
/**
			* Prep Q Encoding
			*
			* Performs "Q Encoding" on a string for use in email headers.
			* It's related but not identical to quoted-printable, so it has its
			* own method.
			*
			* @param	string
			* @return	string
			*/
Prep Q Encoding
Performs "Q Encoding" on a string for use in email headers.
It's related but not identical to quoted-printable, so it has its
own method.

@param        string
@return       string
Prep Q Encoding Performs " Q Encoding " on a string for use in email headers . It ' s related but not identical to quoted - printable so it has its own method . @param string @return string
protected function _prep_q_encoding($str)
			{
				$str = str_replace(array("\r", "\n"), '', $str);
				if ($this->charset === 'UTF-8')
				{
					if (ICONV_ENABLED === TRUE)
					{
						$output = @iconv_mime_encode('', $str,
						array(
							'scheme' => 'Q',
							'line-length' => 76,
							'input-charset' => $this->charset,
							'output-charset' => $this->charset,
							'line-break-chars' => $this->crlf
						)
					);
					if ($output !== FALSE)
					{
						return self::substr($output, 2);
					}
					$chars = iconv_strlen($str, 'UTF-8');
				}
				elseif (MB_ENABLED === TRUE)
				{
					$chars = mb_strlen($str, 'UTF-8');
				}
			}
			isset($chars) OR $chars = self::strlen($str);
			$output = '=?'.$this->charset.'?Q?';
			for ($i = 0, $length = self::strlen($output); $i < $chars; $i++)
			{
				$chr = ($this->charset === 'UTF-8' && ICONV_ENABLED === TRUE)
				? '='.implode('=', str_split(strtoupper(bin2hex(iconv_substr($str, $i, 1, $this->charset))), 2))
				: '='.strtoupper(bin2hex($str[$i]));
				if ($length + ($l = self::strlen($chr)) > 74)
				{
					$output .= '?='.$this->crlf 
					.' =?'.$this->charset.'?Q?'.$chr; 
					$length = 6 + self::strlen($this->charset) + $l; 
				}
				else
				{
					$output .= $chr;
					$length += $l;
				}
			}
			return $output.'?=';
		}
protected function _prep_q_encoding ( $ str ) { $ str = str_replace ( array ( " \r " , " \n " ) , '' , $ str ) ; if ( $ this -> charset === 'UTF-8' ) { if ( ICONV_ENABLED === TRUE ) { $ output = @ iconv_mime_encode ( '' , $ str , array ( 'scheme' => 'Q' , 'line-length' => 76 , 'input-charset' => $ this -> charset , 'output-charset' => $ this -> charset , 'line-break-chars' => $ this -> crlf ) ) ; if ( $ output !== FALSE ) { return self :: substr ( $ output , 2 ) ; } $ chars = iconv_strlen ( $ str , 'UTF-8' ) ; } elseif ( MB_ENABLED === TRUE ) { $ chars = mb_strlen ( $ str , 'UTF-8' ) ; } } isset ( $ chars ) OR $ chars = self :: strlen ( $ str ) ; $ output = '=?' . $ this -> charset . '?Q?' ; for ( $ i = 0 , $ length = self :: strlen ( $ output ) ; $ i < $ chars ; $ i ++ ) { $ chr = ( $ this -> charset === 'UTF-8' && ICONV_ENABLED === TRUE ) ? '=' . implode ( '=' , str_split ( strtoupper ( bin2hex ( iconv_substr ( $ str , $ i , 1 , $ this -> charset ) ) ) , 2 ) ) : '=' . strtoupper ( bin2hex ( $ str [ $ i ] ) ) ; if ( $ length + ( $ l = self :: strlen ( $ chr ) ) > 74 ) { $ output .= '?=' . $ this -> crlf . ' =?' . $ this -> charset . '?Q?' . $ chr ; $ length = 6 + self :: strlen ( $ this -> charset ) + $ l ; } else { $ output .= $ chr ; $ length += $ l ; } } return $ output . '?=' ; }
Prep Q Encoding
 Performs "Q Encoding" on a string for use in email headers.
Prep Q Encoding Performs " Q Encoding " on a string for use in email headers .
// Note: We used to have mb_encode_mimeheader() as the first choice //       here, but it turned out to be buggy and unreliable. DO NOT //       re-add it! -- Narf // There are reports that iconv_mime_encode() might fail and return FALSE // iconv_mime_encode() will always put a header field name. // We've passed it an empty one, but it still prepends our // encoded string with ': ', so we need to strip it. // We might already have this set for UTF-8 // RFC 2045 sets a limit of 76 characters per line. // We'll append ?= to the end of each line though. // EOL // New line // Reset the length for the new line // End the header