iso8859-6.php 3.0 KB

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