Added feature #15998: Create a new API to send mails based on SwiftMailer to replace...
[Packages/TYPO3.CMS.git] / typo3 / contrib / swiftmailer / classes / Swift / CharacterReader / UsAsciiReader.php
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/CharacterReader.php';
12
13 /**
14 * Analyzes US-ASCII characters.
15 * @package Swift
16 * @subpackage Encoder
17 * @author Chris Corbyn
18 */
19 class Swift_CharacterReader_UsAsciiReader
20 implements Swift_CharacterReader
21 {
22 /**
23 * Returns the complete charactermap
24 *
25 * @param string $string
26 * @param int $startOffset
27 * @param string $ignoredChars
28 */
29 public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
30 {
31 $strlen=strlen($string);
32 $ignoredChars='';
33 for( $i = 0; $i < $strlen; ++$i)
34 {
35 if ($string[$i]>"\x07F")
36 { // Invalid char
37 $currentMap[$i+$startOffset]=$string[$i];
38 }
39 }
40 return $strlen;
41 }
42
43 /**
44 * Returns mapType
45 * @int mapType
46 */
47 public function getMapType()
48 {
49 return self::MAP_TYPE_INVALID;
50 }
51
52 /**
53 * Returns an integer which specifies how many more bytes to read.
54 * A positive integer indicates the number of more bytes to fetch before invoking
55 * this method again.
56 * A value of zero means this is already a valid character.
57 * A value of -1 means this cannot possibly be a valid character.
58 * @param string $bytes
59 * @return int
60 */
61 public function validateByteSequence($bytes, $size)
62 {
63 $byte = reset($bytes);
64 if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F)
65 {
66 return 0;
67 }
68 else
69 {
70 return -1;
71 }
72 }
73
74 /**
75 * Returns the number of bytes which should be read to start each character.
76 * @return int
77 */
78 public function getInitialByteSize()
79 {
80 return 1;
81 }
82
83 }