iso_8859_8.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * decode/iso8859-8.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-8 decoding function that is needed to read
  9. * iso-8859-8 encoded mails in non-iso-8859-8 locale.
  10. *
  11. * Original data taken from:
  12. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-8.TXT
  13. *
  14. * Name: ISO/IEC 8859-8:1999 to Unicode
  15. * Unicode version: 3.0
  16. * Table version: 1.1
  17. * Table format: Format A
  18. * Date: 2000-Jan-03
  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-8 encoded strings
  44. * @param string $string Encoded string
  45. * @return string $string Decoded string
  46. */
  47. function charset_decode_iso_8859_8 ($string) {
  48. global $default_charset;
  49. if (strtolower($default_charset) == 'iso8859-8')
  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_8 = array(
  56. "\xA0" => '&#160;',
  57. "\xA2" => '&#162;',
  58. "\xA3" => '&#163;',
  59. "\xA4" => '&#164;',
  60. "\xA5" => '&#165;',
  61. "\xA6" => '&#166;',
  62. "\xA7" => '&#167;',
  63. "\xA8" => '&#168;',
  64. "\xA9" => '&#169;',
  65. "\xAA" => '&#215;',
  66. "\xAB" => '&#171;',
  67. "\xAC" => '&#172;',
  68. "\xAD" => '&#173;',
  69. "\xAE" => '&#174;',
  70. "\xAF" => '&#175;',
  71. "\xB0" => '&#176;',
  72. "\xB1" => '&#177;',
  73. "\xB2" => '&#178;',
  74. "\xB3" => '&#179;',
  75. "\xB4" => '&#180;',
  76. "\xB5" => '&#181;',
  77. "\xB6" => '&#182;',
  78. "\xB7" => '&#183;',
  79. "\xB8" => '&#184;',
  80. "\xB9" => '&#185;',
  81. "\xBA" => '&#247;',
  82. "\xBB" => '&#187;',
  83. "\xBC" => '&#188;',
  84. "\xBD" => '&#189;',
  85. "\xBE" => '&#190;',
  86. "\xDF" => '&#8215;',
  87. "\xE0" => '&#1488;',
  88. "\xE1" => '&#1489;',
  89. "\xE2" => '&#1490;',
  90. "\xE3" => '&#1491;',
  91. "\xE4" => '&#1492;',
  92. "\xE5" => '&#1493;',
  93. "\xE6" => '&#1494;',
  94. "\xE7" => '&#1495;',
  95. "\xE8" => '&#1496;',
  96. "\xE9" => '&#1497;',
  97. "\xEA" => '&#1498;',
  98. "\xEB" => '&#1499;',
  99. "\xEC" => '&#1500;',
  100. "\xED" => '&#1501;',
  101. "\xEE" => '&#1502;',
  102. "\xEF" => '&#1503;',
  103. "\xF0" => '&#1504;',
  104. "\xF1" => '&#1505;',
  105. "\xF2" => '&#1506;',
  106. "\xF3" => '&#1507;',
  107. "\xF4" => '&#1508;',
  108. "\xF5" => '&#1509;',
  109. "\xF6" => '&#1510;',
  110. "\xF7" => '&#1511;',
  111. "\xF8" => '&#1512;',
  112. "\xF9" => '&#1513;',
  113. "\xFA" => '&#1514;',
  114. "\xFD" => '&#8206;',
  115. "\xFE" => '&#8207;'
  116. );
  117. $string = str_replace(array_keys($iso8859_8), array_values($iso8859_8), $string);
  118. return $string;
  119. }
  120. ?>