ECI.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Class ECI
  4. *
  5. * @filesource ECI.php
  6. * @created 20.11.2020
  7. * @package chillerlan\QRCode\Data
  8. * @author smiley <smiley@chillerlan.net>
  9. * @copyright 2020 smiley
  10. * @license MIT
  11. */
  12. namespace chillerlan\QRCode\Data;
  13. use chillerlan\QRCode\Common\{BitBuffer, Mode};
  14. /**
  15. * Adds an ECI Designator
  16. *
  17. * Please note that you have to take care for the correct data encoding when adding with QRCode::add*Segment()
  18. */
  19. class ECI extends QRDataModeAbstract{
  20. public const CP437 = 0; // Code page 437, DOS Latin US
  21. public const ISO_IEC_8859_1_GLI = 1; // GLI encoding with characters 0 to 127 identical to ISO/IEC 646 and characters 128 to 255 identical to ISO 8859-1
  22. public const CP437_WO_GLI = 2; // An equivalent code table to CP437, without the return-to-GLI 0 logic
  23. public const ISO_IEC_8859_1 = 3; // Latin-1 (Default)
  24. public const ISO_IEC_8859_2 = 4; // Latin-2
  25. public const ISO_IEC_8859_3 = 5; // Latin-3
  26. public const ISO_IEC_8859_4 = 6; // Latin-4
  27. public const ISO_IEC_8859_5 = 7; // Latin/Cyrillic
  28. public const ISO_IEC_8859_6 = 8; // Latin/Arabic
  29. public const ISO_IEC_8859_7 = 9; // Latin/Greek
  30. public const ISO_IEC_8859_8 = 10; // Latin/Hebrew
  31. public const ISO_IEC_8859_9 = 11; // Latin-5
  32. public const ISO_IEC_8859_10 = 12; // Latin-6
  33. public const ISO_IEC_8859_11 = 13; // Latin/Thai
  34. // 14 reserved
  35. public const ISO_IEC_8859_13 = 15; // Latin-7 (Baltic Rim)
  36. public const ISO_IEC_8859_14 = 16; // Latin-8 (Celtic)
  37. public const ISO_IEC_8859_15 = 17; // Latin-9
  38. public const ISO_IEC_8859_16 = 18; // Latin-10
  39. // 19 reserved
  40. public const SHIFT_JIS = 20; // JIS X 0208 Annex 1 + JIS X 0201
  41. public const WINDOWS_1250_LATIN_2 = 21; // Superset of Latin-2, Central Europe
  42. public const WINDOWS_1251_CYRILLIC = 22; // Latin/Cyrillic
  43. public const WINDOWS_1252_LATIN_1 = 23; // Superset of Latin-1
  44. public const WINDOWS_1256_ARABIC = 24;
  45. public const ISO_IEC_10646_UCS_2 = 25; // High order byte first (UTF-16BE)
  46. public const ISO_IEC_10646_UTF_8 = 26;
  47. public const ISO_IEC_646_1991 = 27; // International Reference Version of ISO 7-bit coded character set (US-ASCII)
  48. public const BIG5 = 28; // Big 5 (Taiwan) Chinese Character Set
  49. public const GB18030 = 29; // GB (PRC) Chinese Character Set
  50. public const EUC_KR = 30; // Korean Character Set
  51. /**
  52. * The current encoding
  53. */
  54. protected int $encoding;
  55. protected int $datamode = Mode::DATA_ECI;
  56. /**
  57. * @inheritDoc
  58. */
  59. public function __construct(int $encoding){
  60. parent::__construct('');
  61. $this->encoding = $encoding;
  62. }
  63. /**
  64. * @inheritDoc
  65. */
  66. public function getLengthInBits():int{
  67. return 8;
  68. }
  69. /**
  70. * @inheritDoc
  71. */
  72. public static function validateString(string $string):bool{
  73. return true;
  74. }
  75. /**
  76. * @inheritDoc
  77. */
  78. public function write(BitBuffer $bitBuffer, int $versionNumber):void{
  79. $bitBuffer
  80. ->put($this->datamode, 4)
  81. ->put($this->encoding, 8)
  82. ;
  83. }
  84. }