CharacterReader.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Analyzes characters for a specific character set.
  11. * @package Swift
  12. * @subpackage Encoder
  13. * @author Chris Corbyn
  14. * @author Xavier De Cock <xdecock@gmail.com>
  15. */
  16. interface Swift_CharacterReader
  17. {
  18. const MAP_TYPE_INVALID = 0x01;
  19. const MAP_TYPE_FIXED_LEN = 0x02;
  20. const MAP_TYPE_POSITIONS = 0x03;
  21. /**
  22. * Returns the complete charactermap
  23. *
  24. * @param string $string
  25. * @param int $startOffset
  26. * @param array $currentMap
  27. * @param mixed $ignoredChars
  28. * @return int
  29. */
  30. public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars);
  31. /**
  32. * Returns mapType
  33. * @int mapType
  34. */
  35. public function getMapType();
  36. /**
  37. * Returns an integer which specifies how many more bytes to read.
  38. * A positive integer indicates the number of more bytes to fetch before invoking
  39. * this method again.
  40. * A value of zero means this is already a valid character.
  41. * A value of -1 means this cannot possibly be a valid character.
  42. * @param int[] $bytes
  43. * @return int
  44. */
  45. public function validateByteSequence($bytes, $size);
  46. /**
  47. * Returns the number of bytes which should be read to start each character.
  48. * For fixed width character sets this should be the number of
  49. * octets-per-character. For multibyte character sets this will probably be 1.
  50. * @return int
  51. */
  52. public function getInitialByteSize();
  53. }