TYPO3 API  SVNRelease
UsAsciiReader.php
Go to the documentation of this file.
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/CharacterReader.php';
00012 
00013 /**
00014  * Analyzes US-ASCII characters.
00015  * @package Swift
00016  * @subpackage Encoder
00017  * @author Chris Corbyn
00018  */
00019 class Swift_CharacterReader_UsAsciiReader
00020   implements Swift_CharacterReader
00021 {
00022   /**
00023    * Returns the complete charactermap
00024    *
00025    * @param string $string
00026    * @param int $startOffset
00027    * @param string $ignoredChars
00028    */
00029   public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
00030   {
00031     $strlen=strlen($string);
00032     $ignoredChars='';
00033     for( $i = 0; $i < $strlen; ++$i)
00034     {
00035       if ($string[$i]>"\x07F")
00036       { // Invalid char
00037         $currentMap[$i+$startOffset]=$string[$i];
00038       }
00039     }
00040     return $strlen;
00041   }
00042 
00043   /**
00044    * Returns mapType
00045    * @int mapType
00046    */
00047   public function getMapType()
00048   {
00049     return self::MAP_TYPE_INVALID;
00050   }
00051 
00052   /**
00053    * Returns an integer which specifies how many more bytes to read.
00054    * A positive integer indicates the number of more bytes to fetch before invoking
00055    * this method again.
00056    * A value of zero means this is already a valid character.
00057    * A value of -1 means this cannot possibly be a valid character.
00058    * @param string $bytes
00059    * @return int
00060    */
00061   public function validateByteSequence($bytes, $size)
00062   {
00063     $byte = reset($bytes);
00064     if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F)
00065     {
00066       return 0;
00067     }
00068     else
00069     {
00070       return -1;
00071     }
00072   }
00073 
00074   /**
00075    * Returns the number of bytes which should be read to start each character.
00076    * @return int
00077    */
00078   public function getInitialByteSize()
00079   {
00080     return 1;
00081   }
00082 
00083 }