|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /* 00004 * This file is part of SwiftMailer. 00005 * (c) 2004-2009 Chris Corbyn 00006 * 00007 * For the full copyright and license information, please view the LICENSE 00008 * file that was distributed with this source code. 00009 */ 00010 00011 //@require 'Swift/Encoder.php'; 00012 00013 /** 00014 * Handles Base 64 Encoding in Swift Mailer. 00015 * @package Swift 00016 * @subpackage Encoder 00017 * @author Chris Corbyn 00018 */ 00019 class Swift_Encoder_Base64Encoder implements Swift_Encoder 00020 { 00021 00022 /** 00023 * Takes an unencoded string and produces a Base64 encoded string from it. 00024 * Base64 encoded strings have a maximum line length of 76 characters. 00025 * If the first line needs to be shorter, indicate the difference with 00026 * $firstLineOffset. 00027 * @param string $string to encode 00028 * @param int $firstLineOffset 00029 * @param int $maxLineLength, optional, 0 indicates the default of 76 bytes 00030 * @return string 00031 */ 00032 public function encodeString($string, $firstLineOffset = 0, 00033 $maxLineLength = 0) 00034 { 00035 if (0 >= $maxLineLength || 76 < $maxLineLength) 00036 { 00037 $maxLineLength = 76; 00038 } 00039 00040 $encodedString = base64_encode($string); 00041 $firstLine = ''; 00042 00043 if (0 != $firstLineOffset) 00044 { 00045 $firstLine = substr( 00046 $encodedString, 0, $maxLineLength - $firstLineOffset 00047 ) . "\r\n"; 00048 $encodedString = substr( 00049 $encodedString, $maxLineLength - $firstLineOffset 00050 ); 00051 } 00052 00053 return $firstLine . trim(chunk_split($encodedString, $maxLineLength, "\r\n")); 00054 } 00055 00056 /** 00057 * Does nothing. 00058 */ 00059 public function charsetChanged($charset) 00060 { 00061 } 00062 00063 }
1.8.0