| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * decode/tis620.php |
| 5 | * |
| 6 | * This file contains tis620 decoding function that is needed to read |
| 7 | * tis620 encoded mails in non-tis620 locale. |
| 8 | * |
| 9 | * Original data taken from: |
| 10 | * http://www.inet.co.th/cyberclub/trin/thairef/tis620-iso10646.html |
| 11 | * |
| 12 | * Original copyright: |
| 13 | * Note: The information contained herein is provided as-is. It was |
| 14 | * complied from various references given at the end of the page. |
| 15 | * The author (trin@mozart.inet.co.th) believes all information |
| 16 | * presented here is accurate. |
| 17 | * |
| 18 | * References |
| 19 | * 1. [1]TIS 620-2533 Standard for Thai Character Codes for Computers |
| 20 | * (in Thai), [2]Thai Industrial Standards Institute |
| 21 | * 2. [3]Thai Information Technology Standards, On-line resources at the |
| 22 | * National Electronics and Computer Technology Center (NECTEC) |
| 23 | * 3. ISO/IEC 10646-1, [4]ISO/IEC JTC1/SC2 |
| 24 | * 4. [5]Thai block in Unicode 2.1, [6]Unicode Consortium |
| 25 | * |
| 26 | * Links |
| 27 | * 1. http://www.nectec.or.th/it-standards/std620/std620.htm |
| 28 | * 2. http://www.tisi.go.th/ |
| 29 | * 3. http://www.nectec.or.th/it-standards/ |
| 30 | * 4. http://wwwold.dkuug.dk/JTC1/SC2/ |
| 31 | * 5. http://charts.unicode.org/Unicode.charts/normal/U0E00.html |
| 32 | * 6. http://www.unicode.org/ |
| 33 | * |
| 34 | * @copyright 2003-2018 The SquirrelMail Project Team |
| 35 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 36 | * @version $Id$ |
| 37 | * @package squirrelmail |
| 38 | * @subpackage decode |
| 39 | */ |
| 40 | |
| 41 | /** |
| 42 | * Decode tis620 encoded strings |
| 43 | * @param string $string Encoded string |
| 44 | * @return string Decoded string |
| 45 | */ |
| 46 | function charset_decode_tis_620 ($string) { |
| 47 | // don't do decoding when there are no 8bit symbols |
| 48 | if (! sq_is8bit($string,'tis-620')) |
| 49 | return $string; |
| 50 | |
| 51 | $tis620 = array( |
| 52 | "\xA0" => '', |
| 53 | "\xA1" => 'ก', |
| 54 | "\xA2" => 'ข', |
| 55 | "\xA3" => 'ฃ', |
| 56 | "\xA4" => 'ค', |
| 57 | "\xA5" => 'ฅ', |
| 58 | "\xA6" => 'ฆ', |
| 59 | "\xA7" => 'ง', |
| 60 | "\xA8" => 'จ', |
| 61 | "\xA9" => 'ฉ', |
| 62 | "\xAA" => 'ช', |
| 63 | "\xAB" => 'ซ', |
| 64 | "\xAC" => 'ฌ', |
| 65 | "\xAD" => 'ญ', |
| 66 | "\xAE" => 'ฎ', |
| 67 | "\xAF" => 'ฏ', |
| 68 | "\xB0" => 'ฐ', |
| 69 | "\xB1" => 'ฑ', |
| 70 | "\xB2" => 'ฒ', |
| 71 | "\xB3" => 'ณ', |
| 72 | "\xB4" => 'ด', |
| 73 | "\xB5" => 'ต', |
| 74 | "\xB6" => 'ถ', |
| 75 | "\xB7" => 'ท', |
| 76 | "\xB8" => 'ธ', |
| 77 | "\xB9" => 'น', |
| 78 | "\xBA" => 'บ', |
| 79 | "\xBB" => 'ป', |
| 80 | "\xBC" => 'ผ', |
| 81 | "\xBD" => 'ฝ', |
| 82 | "\xBE" => 'พ', |
| 83 | "\xBF" => 'ฟ', |
| 84 | "\xC0" => 'ภ', |
| 85 | "\xC1" => 'ม', |
| 86 | "\xC2" => 'ย', |
| 87 | "\xC3" => 'ร', |
| 88 | "\xC4" => 'ฤ', |
| 89 | "\xC5" => 'ล', |
| 90 | "\xC6" => 'ฦ', |
| 91 | "\xC7" => 'ว', |
| 92 | "\xC8" => 'ศ', |
| 93 | "\xC9" => 'ษ', |
| 94 | "\xCA" => 'ส', |
| 95 | "\xCB" => 'ห', |
| 96 | "\xCC" => 'ฬ', |
| 97 | "\xCD" => 'อ', |
| 98 | "\xCE" => 'ฮ', |
| 99 | "\xCF" => 'ฯ', |
| 100 | "\xD0" => 'ะ', |
| 101 | "\xD1" => 'ั', |
| 102 | "\xD2" => 'า', |
| 103 | "\xD3" => 'ำ', |
| 104 | "\xD4" => 'ิ', |
| 105 | "\xD5" => 'ี', |
| 106 | "\xD6" => 'ึ', |
| 107 | "\xD7" => 'ื', |
| 108 | "\xD8" => 'ุ', |
| 109 | "\xD9" => 'ู', |
| 110 | "\xDA" => 'ฺ', |
| 111 | "\xDB" => '', |
| 112 | "\xDC" => '', |
| 113 | "\xDD" => '', |
| 114 | "\xDE" => '', |
| 115 | "\xDF" => '฿', |
| 116 | "\xE0" => 'เ', |
| 117 | "\xE1" => 'แ', |
| 118 | "\xE2" => 'โ', |
| 119 | "\xE3" => 'ใ', |
| 120 | "\xE4" => 'ไ', |
| 121 | "\xE5" => 'ๅ', |
| 122 | "\xE6" => 'ๆ', |
| 123 | "\xE7" => '็', |
| 124 | "\xE8" => '่', |
| 125 | "\xE9" => '้', |
| 126 | "\xEA" => '๊', |
| 127 | "\xEB" => '๋', |
| 128 | "\xEC" => '์', |
| 129 | "\xED" => 'ํ', |
| 130 | "\xEE" => '๎', |
| 131 | "\xEF" => '๏', |
| 132 | "\xF0" => '๐', |
| 133 | "\xF1" => '๑', |
| 134 | "\xF2" => '๒', |
| 135 | "\xF3" => '๓', |
| 136 | "\xF4" => '๔', |
| 137 | "\xF5" => '๕', |
| 138 | "\xF6" => '๖', |
| 139 | "\xF7" => '๗', |
| 140 | "\xF8" => '๘', |
| 141 | "\xF9" => '๙', |
| 142 | "\xFA" => '๚', |
| 143 | "\xFB" => '๛', |
| 144 | "\xFC" => '', |
| 145 | "\xFD" => '', |
| 146 | "\xFE" => '', |
| 147 | "\xFF" => '' |
| 148 | ); |
| 149 | |
| 150 | $string = str_replace(array_keys($tis620), array_values($tis620), $string); |
| 151 | |
| 152 | return $string; |
| 153 | } |