XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
Base64Encoder.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of SwiftMailer.
5  * (c) 2004-2009 Chris Corbyn
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10 
11 //@require 'Swift/Encoder.php';
12 
20 {
21 
32  public function encodeString($string, $firstLineOffset = 0,
33  $maxLineLength = 0)
34  {
35  if (0 >= $maxLineLength || 76 < $maxLineLength)
36  {
37  $maxLineLength = 76;
38  }
39 
40  $encodedString = base64_encode($string);
41  $firstLine = '';
42 
43  if (0 != $firstLineOffset)
44  {
45  $firstLine = substr(
46  $encodedString, 0, $maxLineLength - $firstLineOffset
47  ) . "\r\n";
48  $encodedString = substr(
49  $encodedString, $maxLineLength - $firstLineOffset
50  );
51  }
52 
53  return $firstLine . trim(chunk_split($encodedString, $maxLineLength, "\r\n"));
54  }
55 
59  public function charsetChanged($charset)
60  {
61  }
62 
63 }