CharacterReader.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. *
  12. * @author Chris Corbyn
  13. * @author Xavier De Cock <xdecock@gmail.com>
  14. */
  15. interface Swift_CharacterReader
  16. {
  17. const MAP_TYPE_INVALID = 0x01;
  18. const MAP_TYPE_FIXED_LEN = 0x02;
  19. const MAP_TYPE_POSITIONS = 0x03;
  20. /**
  21. * Returns the complete character map
  22. *
  23. * @param string $string
  24. * @param int $startOffset
  25. * @param array $currentMap
  26. * @param mixed $ignoredChars
  27. *
  28. * @return int
  29. */
  30. public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars);
  31. /**
  32. * Returns the mapType, see constants.
  33. *
  34. * @return int
  35. */
  36. public function getMapType();
  37. /**
  38. * Returns an integer which specifies how many more bytes to read.
  39. *
  40. * A positive integer indicates the number of more bytes to fetch before invoking
  41. * this method again.
  42. *
  43. * A value of zero means this is already a valid character.
  44. * A value of -1 means this cannot possibly be a valid character.
  45. *
  46. * @param integer[] $bytes
  47. * @param int $size
  48. *
  49. * @return int
  50. */
  51. public function validateByteSequence($bytes, $size);
  52. /**
  53. * Returns the number of bytes which should be read to start each character.
  54. *
  55. * For fixed width character sets this should be the number of octets-per-character.
  56. * For multibyte character sets this will probably be 1.
  57. *
  58. * @return int
  59. */
  60. public function getInitialByteSize();
  61. }