tis_620.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /**
  3. * decode/tis620.php
  4. *
  5. * This file contains tis620 decoding function that is needed to read
  6. * tis620 encoded mails in non-tis620 locale.
  7. *
  8. * Original data taken from:
  9. * http://www.inet.co.th/cyberclub/trin/thairef/tis620-iso10646.html
  10. *
  11. * Original copyright:
  12. * Note: The information contained herein is provided as-is. It was
  13. * complied from various references given at the end of the page.
  14. * The author (trin@mozart.inet.co.th) believes all information
  15. * presented here is accurate.
  16. *
  17. * References
  18. * 1. [1]TIS 620-2533 Standard for Thai Character Codes for Computers
  19. * (in Thai), [2]Thai Industrial Standards Institute
  20. * 2. [3]Thai Information Technology Standards, On-line resources at the
  21. * National Electronics and Computer Technology Center (NECTEC)
  22. * 3. ISO/IEC 10646-1, [4]ISO/IEC JTC1/SC2
  23. * 4. [5]Thai block in Unicode 2.1, [6]Unicode Consortium
  24. *
  25. * Links
  26. * 1. http://www.nectec.or.th/it-standards/std620/std620.htm
  27. * 2. http://www.tisi.go.th/
  28. * 3. http://www.nectec.or.th/it-standards/
  29. * 4. http://wwwold.dkuug.dk/JTC1/SC2/
  30. * 5. http://charts.unicode.org/Unicode.charts/normal/U0E00.html
  31. * 6. http://www.unicode.org/
  32. *
  33. * @copyright 2003-2025 The SquirrelMail Project Team
  34. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  35. * @version $Id$
  36. * @package squirrelmail
  37. * @subpackage decode
  38. */
  39. /**
  40. * Decode tis620 encoded strings
  41. * @param string $string Encoded string
  42. * @return string Decoded string
  43. */
  44. function charset_decode_tis_620 ($string) {
  45. // don't do decoding when there are no 8bit symbols
  46. if (! sq_is8bit($string,'tis-620'))
  47. return $string;
  48. $tis620 = array(
  49. "\xA0" => '&#65535;',
  50. "\xA1" => '&#3585;',
  51. "\xA2" => '&#3586;',
  52. "\xA3" => '&#3587;',
  53. "\xA4" => '&#3588;',
  54. "\xA5" => '&#3589;',
  55. "\xA6" => '&#3590;',
  56. "\xA7" => '&#3591;',
  57. "\xA8" => '&#3592;',
  58. "\xA9" => '&#3593;',
  59. "\xAA" => '&#3594;',
  60. "\xAB" => '&#3595;',
  61. "\xAC" => '&#3596;',
  62. "\xAD" => '&#3597;',
  63. "\xAE" => '&#3598;',
  64. "\xAF" => '&#3599;',
  65. "\xB0" => '&#3600;',
  66. "\xB1" => '&#3601;',
  67. "\xB2" => '&#3602;',
  68. "\xB3" => '&#3603;',
  69. "\xB4" => '&#3604;',
  70. "\xB5" => '&#3605;',
  71. "\xB6" => '&#3606;',
  72. "\xB7" => '&#3607;',
  73. "\xB8" => '&#3608;',
  74. "\xB9" => '&#3609;',
  75. "\xBA" => '&#3610;',
  76. "\xBB" => '&#3611;',
  77. "\xBC" => '&#3612;',
  78. "\xBD" => '&#3613;',
  79. "\xBE" => '&#3614;',
  80. "\xBF" => '&#3615;',
  81. "\xC0" => '&#3616;',
  82. "\xC1" => '&#3617;',
  83. "\xC2" => '&#3618;',
  84. "\xC3" => '&#3619;',
  85. "\xC4" => '&#3620;',
  86. "\xC5" => '&#3621;',
  87. "\xC6" => '&#3622;',
  88. "\xC7" => '&#3623;',
  89. "\xC8" => '&#3624;',
  90. "\xC9" => '&#3625;',
  91. "\xCA" => '&#3626;',
  92. "\xCB" => '&#3627;',
  93. "\xCC" => '&#3628;',
  94. "\xCD" => '&#3629;',
  95. "\xCE" => '&#3630;',
  96. "\xCF" => '&#3631;',
  97. "\xD0" => '&#3632;',
  98. "\xD1" => '&#3633;',
  99. "\xD2" => '&#3634;',
  100. "\xD3" => '&#3635;',
  101. "\xD4" => '&#3636;',
  102. "\xD5" => '&#3637;',
  103. "\xD6" => '&#3638;',
  104. "\xD7" => '&#3639;',
  105. "\xD8" => '&#3640;',
  106. "\xD9" => '&#3641;',
  107. "\xDA" => '&#3642;',
  108. "\xDB" => '&#65535;',
  109. "\xDC" => '&#65535;',
  110. "\xDD" => '&#65535;',
  111. "\xDE" => '&#65535;',
  112. "\xDF" => '&#3647;',
  113. "\xE0" => '&#3648;',
  114. "\xE1" => '&#3649;',
  115. "\xE2" => '&#3650;',
  116. "\xE3" => '&#3651;',
  117. "\xE4" => '&#3652;',
  118. "\xE5" => '&#3653;',
  119. "\xE6" => '&#3654;',
  120. "\xE7" => '&#3655;',
  121. "\xE8" => '&#3656;',
  122. "\xE9" => '&#3657;',
  123. "\xEA" => '&#3658;',
  124. "\xEB" => '&#3659;',
  125. "\xEC" => '&#3660;',
  126. "\xED" => '&#3661;',
  127. "\xEE" => '&#3662;',
  128. "\xEF" => '&#3663;',
  129. "\xF0" => '&#3664;',
  130. "\xF1" => '&#3665;',
  131. "\xF2" => '&#3666;',
  132. "\xF3" => '&#3667;',
  133. "\xF4" => '&#3668;',
  134. "\xF5" => '&#3669;',
  135. "\xF6" => '&#3670;',
  136. "\xF7" => '&#3671;',
  137. "\xF8" => '&#3672;',
  138. "\xF9" => '&#3673;',
  139. "\xFA" => '&#3674;',
  140. "\xFB" => '&#3675;',
  141. "\xFC" => '&#65535;',
  142. "\xFD" => '&#65535;',
  143. "\xFE" => '&#65535;',
  144. "\xFF" => '&#65535;'
  145. );
  146. $string = str_replace(array_keys($tis620), array_values($tis620), $string);
  147. return $string;
  148. }