tis_620.php 4.5 KB

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