iso_8859_6.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * decode/iso8859-6.php
  4. *
  5. * This file contains iso-8859-6 decoding function that is needed to read
  6. * iso-8859-6 encoded mails in non-iso-8859-6 locale.
  7. *
  8. * Original data taken from:
  9. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-6.TXT
  10. *
  11. * Name: ISO 8859-6:1999 to Unicode
  12. * Unicode version: 3.0
  13. * Table version: 1.0
  14. * Table format: Format A
  15. * Date: 1999 July 27
  16. * Authors: Ken Whistler <kenw@sybase.com>
  17. *
  18. * Original copyright:
  19. * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
  20. *
  21. * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
  22. * No claims are made as to fitness for any particular purpose. No
  23. * warranties of any kind are expressed or implied. The recipient
  24. * agrees to determine applicability of information provided. If this
  25. * file has been provided on optical media by Unicode, Inc., the sole
  26. * remedy for any claim will be exchange of defective media within 90
  27. * days of receipt.
  28. *
  29. * Unicode, Inc. hereby grants the right to freely use the information
  30. * supplied in this file in the creation of products supporting the
  31. * Unicode Standard, and to make copies of this file in any form for
  32. * internal or external distribution as long as this notice remains
  33. * attached.
  34. *
  35. * @copyright &copy; 2003-2006 The SquirrelMail Project Team
  36. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  37. * @version $Id$
  38. * @package squirrelmail
  39. * @subpackage decode
  40. */
  41. /**
  42. * Decode iso8859-6 strings
  43. * @param string $string Encoded string
  44. * @return string $string Decoded string
  45. */
  46. function charset_decode_iso_8859_6 ($string) {
  47. // don't do decoding when there are no 8bit symbols
  48. if (! sq_is8bit($string,'iso-8859-6'))
  49. return $string;
  50. $iso8859_6 = array(
  51. "\xA0" => '&#160;',
  52. "\xA4" => '&#164;',
  53. "\xAC" => '&#1548;',
  54. "\xAD" => '&#173;',
  55. "\xBB" => '&#1563;',
  56. "\xBF" => '&#1567;',
  57. "\xC1" => '&#1569;',
  58. "\xC2" => '&#1570;',
  59. "\xC3" => '&#1571;',
  60. "\xC4" => '&#1572;',
  61. "\xC5" => '&#1573;',
  62. "\xC6" => '&#1574;',
  63. "\xC7" => '&#1575;',
  64. "\xC8" => '&#1576;',
  65. "\xC9" => '&#1577;',
  66. "\xCA" => '&#1578;',
  67. "\xCB" => '&#1579;',
  68. "\xCC" => '&#1580;',
  69. "\xCD" => '&#1581;',
  70. "\xCE" => '&#1582;',
  71. "\xCF" => '&#1583;',
  72. "\xD0" => '&#1584;',
  73. "\xD1" => '&#1585;',
  74. "\xD2" => '&#1586;',
  75. "\xD3" => '&#1587;',
  76. "\xD4" => '&#1588;',
  77. "\xD5" => '&#1589;',
  78. "\xD6" => '&#1590;',
  79. "\xD7" => '&#1591;',
  80. "\xD8" => '&#1592;',
  81. "\xD9" => '&#1593;',
  82. "\xDA" => '&#1594;',
  83. "\xE0" => '&#1600;',
  84. "\xE1" => '&#1601;',
  85. "\xE2" => '&#1602;',
  86. "\xE3" => '&#1603;',
  87. "\xE4" => '&#1604;',
  88. "\xE5" => '&#1605;',
  89. "\xE6" => '&#1606;',
  90. "\xE7" => '&#1607;',
  91. "\xE8" => '&#1608;',
  92. "\xE9" => '&#1609;',
  93. "\xEA" => '&#1610;',
  94. "\xEB" => '&#1611;',
  95. "\xEC" => '&#1612;',
  96. "\xED" => '&#1613;',
  97. "\xEE" => '&#1614;',
  98. "\xEF" => '&#1615;',
  99. "\xF0" => '&#1616;',
  100. "\xF1" => '&#1617;',
  101. "\xF2" => '&#1618;'
  102. );
  103. $string = str_replace(array_keys($iso8859_6), array_values($iso8859_6), $string);
  104. return $string;
  105. }