iso_8859_6.php 3.2 KB

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