CharacterReader.php 1.8KB

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