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