<?php
+
/**
* decode/tis620.php
*
- * Copyright (c) 2003-2004 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
* This file contains tis620 decoding function that is needed to read
* tis620 encoded mails in non-tis620 locale.
- *
+ *
* Original data taken from:
* http://www.inet.co.th/cyberclub/trin/thairef/tis620-iso10646.html
*
* Original copyright:
* Note: The information contained herein is provided as-is. It was
* complied from various references given at the end of the page.
- * The author (trin@mozart.inet.co.th) believes all information
+ * The author (trin@mozart.inet.co.th) believes all information
* presented here is accurate.
*
* References
* 5. http://charts.unicode.org/Unicode.charts/normal/U0E00.html
* 6. http://www.unicode.org/
*
+ * @copyright 2003-2017 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
* @subpackage decode
* @return string Decoded string
*/
function charset_decode_tis_620 ($string) {
- global $default_charset;
-
- if (strtolower($default_charset) == 'tis-620')
- return $string;
-
- /* Only do the slow convert if there are 8-bit characters */
- /* there is no 0x80-0x9F letters in TIS620 */
- if ( ! ereg("[\241-\377]", $string) )
+ // don't do decoding when there are no 8bit symbols
+ if (! sq_is8bit($string,'tis-620'))
return $string;
$tis620 = array(
- "\xA0" => '',
- "\xA1" => 'ก',
- "\xA2" => 'ข',
- "\xA3" => 'ฃ',
- "\xA4" => 'ค',
- "\xA5" => 'ฅ',
- "\xA6" => 'ฆ',
- "\xA7" => 'ง',
- "\xA8" => 'จ',
- "\xA9" => 'ฉ',
- "\xAA" => 'ช',
- "\xAB" => 'ซ',
- "\xAC" => 'ฌ',
- "\xAD" => 'ญ',
- "\xAE" => 'ฎ',
- "\xAF" => 'ฏ',
- "\xB0" => 'ฐ',
- "\xB1" => 'ฑ',
- "\xB2" => 'ฒ',
- "\xB3" => 'ณ',
- "\xB4" => 'ด',
- "\xB5" => 'ต',
- "\xB6" => 'ถ',
- "\xB7" => 'ท',
- "\xB8" => 'ธ',
- "\xB9" => 'น',
- "\xBA" => 'บ',
- "\xBB" => 'ป',
- "\xBC" => 'ผ',
- "\xBD" => 'ฝ',
- "\xBE" => 'พ',
- "\xBF" => 'ฟ',
- "\xC0" => 'ภ',
- "\xC1" => 'ม',
- "\xC2" => 'ย',
- "\xC3" => 'ร',
- "\xC4" => 'ฤ',
- "\xC5" => 'ล',
- "\xC6" => 'ฦ',
- "\xC7" => 'ว',
- "\xC8" => 'ศ',
- "\xC9" => 'ษ',
- "\xCA" => 'ส',
- "\xCB" => 'ห',
- "\xCC" => 'ฬ',
- "\xCD" => 'อ',
- "\xCE" => 'ฮ',
- "\xCF" => 'ฯ',
- "\xD0" => 'ะ',
- "\xD1" => 'ั',
- "\xD2" => 'า',
- "\xD3" => 'ำ',
- "\xD4" => 'ิ',
- "\xD5" => 'ี',
- "\xD6" => 'ึ',
- "\xD7" => 'ื',
- "\xD8" => 'ุ',
- "\xD9" => 'ู',
- "\xDA" => 'ฺ',
- "\xDB" => '',
- "\xDC" => '',
- "\xDD" => '',
- "\xDE" => '',
- "\xDF" => '฿',
- "\xE0" => 'เ',
- "\xE1" => 'แ',
- "\xE2" => 'โ',
- "\xE3" => 'ใ',
- "\xE4" => 'ไ',
- "\xE5" => 'ๅ',
- "\xE6" => 'ๆ',
- "\xE7" => '็',
- "\xE8" => '่',
- "\xE9" => '้',
- "\xEA" => '๊',
- "\xEB" => '๋',
- "\xEC" => '์',
- "\xED" => 'ํ',
- "\xEE" => '๎',
- "\xEF" => '๏',
- "\xF0" => '๐',
- "\xF1" => '๑',
- "\xF2" => '๒',
- "\xF3" => '๓',
- "\xF4" => '๔',
- "\xF5" => '๕',
- "\xF6" => '๖',
- "\xF7" => '๗',
- "\xF8" => '๘',
- "\xF9" => '๙',
- "\xFA" => '๚',
- "\xFB" => '๛',
- "\xFC" => '',
- "\xFD" => '',
- "\xFE" => '',
- "\xFF" => ''
- );
+ "\xA0" => '',
+ "\xA1" => 'ก',
+ "\xA2" => 'ข',
+ "\xA3" => 'ฃ',
+ "\xA4" => 'ค',
+ "\xA5" => 'ฅ',
+ "\xA6" => 'ฆ',
+ "\xA7" => 'ง',
+ "\xA8" => 'จ',
+ "\xA9" => 'ฉ',
+ "\xAA" => 'ช',
+ "\xAB" => 'ซ',
+ "\xAC" => 'ฌ',
+ "\xAD" => 'ญ',
+ "\xAE" => 'ฎ',
+ "\xAF" => 'ฏ',
+ "\xB0" => 'ฐ',
+ "\xB1" => 'ฑ',
+ "\xB2" => 'ฒ',
+ "\xB3" => 'ณ',
+ "\xB4" => 'ด',
+ "\xB5" => 'ต',
+ "\xB6" => 'ถ',
+ "\xB7" => 'ท',
+ "\xB8" => 'ธ',
+ "\xB9" => 'น',
+ "\xBA" => 'บ',
+ "\xBB" => 'ป',
+ "\xBC" => 'ผ',
+ "\xBD" => 'ฝ',
+ "\xBE" => 'พ',
+ "\xBF" => 'ฟ',
+ "\xC0" => 'ภ',
+ "\xC1" => 'ม',
+ "\xC2" => 'ย',
+ "\xC3" => 'ร',
+ "\xC4" => 'ฤ',
+ "\xC5" => 'ล',
+ "\xC6" => 'ฦ',
+ "\xC7" => 'ว',
+ "\xC8" => 'ศ',
+ "\xC9" => 'ษ',
+ "\xCA" => 'ส',
+ "\xCB" => 'ห',
+ "\xCC" => 'ฬ',
+ "\xCD" => 'อ',
+ "\xCE" => 'ฮ',
+ "\xCF" => 'ฯ',
+ "\xD0" => 'ะ',
+ "\xD1" => 'ั',
+ "\xD2" => 'า',
+ "\xD3" => 'ำ',
+ "\xD4" => 'ิ',
+ "\xD5" => 'ี',
+ "\xD6" => 'ึ',
+ "\xD7" => 'ื',
+ "\xD8" => 'ุ',
+ "\xD9" => 'ู',
+ "\xDA" => 'ฺ',
+ "\xDB" => '',
+ "\xDC" => '',
+ "\xDD" => '',
+ "\xDE" => '',
+ "\xDF" => '฿',
+ "\xE0" => 'เ',
+ "\xE1" => 'แ',
+ "\xE2" => 'โ',
+ "\xE3" => 'ใ',
+ "\xE4" => 'ไ',
+ "\xE5" => 'ๅ',
+ "\xE6" => 'ๆ',
+ "\xE7" => '็',
+ "\xE8" => '่',
+ "\xE9" => '้',
+ "\xEA" => '๊',
+ "\xEB" => '๋',
+ "\xEC" => '์',
+ "\xED" => 'ํ',
+ "\xEE" => '๎',
+ "\xEF" => '๏',
+ "\xF0" => '๐',
+ "\xF1" => '๑',
+ "\xF2" => '๒',
+ "\xF3" => '๓',
+ "\xF4" => '๔',
+ "\xF5" => '๕',
+ "\xF6" => '๖',
+ "\xF7" => '๗',
+ "\xF8" => '๘',
+ "\xF9" => '๙',
+ "\xFA" => '๚',
+ "\xFB" => '๛',
+ "\xFC" => '',
+ "\xFD" => '',
+ "\xFE" => '',
+ "\xFF" => ''
+ );
$string = str_replace(array_keys($tis620), array_values($tis620), $string);
return $string;
}
-
-?>