Skip to content

Commit

Permalink
The utf8_char_boundary function was no longer used.
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdejonge committed Oct 23, 2011
1 parent 030c6b3 commit b18106a
Showing 1 changed file with 3 additions and 54 deletions.
57 changes: 3 additions & 54 deletions classes/email/driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -952,57 +952,6 @@ protected function build_message()
);
}

/**
* Returns the uft8 character boundary
*
* @param string $encoded_text utf-8 encoded text
* @param int $max_length the max boundary position
* @return int the fount char boundary
*/
public static function utf8_char_boundary($encoded_text, $max_length) {
$found_split_pos = false;
$look_back = 3;
while ( ! $found_split_pos)
{
$last_chunk = substr($encoded_text, $max_length - $look_back, $look_back);
$encoded_char_pos = strpos($last_chunk, '=');
if ($encoded_char_pos !== false)
{
// Found start of encoded character byte within $lookBack block.
// Check the encoded byte value (the 2 chars after the '=')
$hex = substr($encoded_text, $max_length - $look_back + $encoded_char_pos + 1, 2);
$dec = hexdec($hex);
if ($dec < 128)
{
// Single byte character.
// If the encoded char was found at pos 0, it will fit
// otherwise reduce maxLength to start of the encoded char
$max_length = ($encoded_char_pos == 0) ? $max_length :
$max_length - ($look_back - $encoded_char_pos);
$found_split_pos = true;
}
elseif ($dec >= 192)
{
// First byte of a multi byte character
// Reduce maxLength to split at start of character
$max_length = $max_length - ($look_back - $encoded_char_pos);
$foundSplitPos = true;
}
elseif ($dec < 192)
{
// Middle byte of a multi byte character, look further back
$lookBack += 3;
}
}
else
{
// No encoded character found
$found_split_pos = true;
}
}
return $max_length;
}

/**
* Wraps the body or alt text
*
Expand Down Expand Up @@ -1030,7 +979,7 @@ protected static function wrap_text($message, $length, $newline, $is_html = true
*/
protected static function prep_newlines($string, $newline = null)
{
$newline or $newline = \Config::get('email.defaults.newline');
$newline or $newline = \Config::get('email.defaults.newline', "\n");

$replace = array(
"\r\n" => "\n",
Expand All @@ -1054,9 +1003,9 @@ protected static function prep_newlines($string, $newline = null)
* @param string $encoding the charset
* @return string encoded string
*/
public static function encode_string($string, $encoding, $newline = null)
protected static function encode_string($string, $encoding, $newline = null)
{
$newline or $newline = \Config::get('email.defaults.newline', "\r\n");
$newline or $newline = \Config::get('email.defaults.newline', "\n");

switch ($encoding)
{
Expand Down

0 comments on commit b18106a

Please sign in to comment.