iso_8859_7.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * decode/iso8859-7.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-7 decoding function that is needed to read
  9. * iso-8859-7 encoded mails in non-iso-8859-7 locale.
  10. *
  11. * Original data taken from:
  12. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-7.TXT
  13. *
  14. * Name: ISO 8859-7:1987 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-7 encoded strings
  44. * @param string $string Encoded string
  45. * @return string $string Decoded string
  46. */
  47. function charset_decode_iso_8859_7 ($string) {
  48. global $default_charset;
  49. if (strtolower($default_charset) == 'iso-8859-7')
  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_7 = array(
  56. "\xA0" => '&#160;',
  57. "\xA1" => '&#8216;',
  58. "\xA2" => '&#8217;',
  59. "\xA3" => '&#163;',
  60. "\xA6" => '&#166;',
  61. "\xA7" => '&#167;',
  62. "\xA8" => '&#168;',
  63. "\xA9" => '&#169;',
  64. "\xAB" => '&#171;',
  65. "\xAC" => '&#172;',
  66. "\xAD" => '&#173;',
  67. "\xAF" => '&#8213;',
  68. "\xB0" => '&#176;',
  69. "\xB1" => '&#177;',
  70. "\xB2" => '&#178;',
  71. "\xB3" => '&#179;',
  72. "\xB4" => '&#900;',
  73. "\xB5" => '&#901;',
  74. "\xB6" => '&#902;',
  75. "\xB7" => '&#183;',
  76. "\xB8" => '&#904;',
  77. "\xB9" => '&#905;',
  78. "\xBA" => '&#906;',
  79. "\xBB" => '&#187;',
  80. "\xBC" => '&#908;',
  81. "\xBD" => '&#189;',
  82. "\xBE" => '&#910;',
  83. "\xBF" => '&#911;',
  84. "\xC0" => '&#912;',
  85. "\xC1" => '&#913;',
  86. "\xC2" => '&#914;',
  87. "\xC3" => '&#915;',
  88. "\xC4" => '&#916;',
  89. "\xC5" => '&#917;',
  90. "\xC6" => '&#918;',
  91. "\xC7" => '&#919;',
  92. "\xC8" => '&#920;',
  93. "\xC9" => '&#921;',
  94. "\xCA" => '&#922;',
  95. "\xCB" => '&#923;',
  96. "\xCC" => '&#924;',
  97. "\xCD" => '&#925;',
  98. "\xCE" => '&#926;',
  99. "\xCF" => '&#927;',
  100. "\xD0" => '&#928;',
  101. "\xD1" => '&#929;',
  102. "\xD3" => '&#931;',
  103. "\xD4" => '&#932;',
  104. "\xD5" => '&#933;',
  105. "\xD6" => '&#934;',
  106. "\xD7" => '&#935;',
  107. "\xD8" => '&#936;',
  108. "\xD9" => '&#937;',
  109. "\xDA" => '&#938;',
  110. "\xDB" => '&#939;',
  111. "\xDC" => '&#940;',
  112. "\xDD" => '&#941;',
  113. "\xDE" => '&#942;',
  114. "\xDF" => '&#943;',
  115. "\xE0" => '&#944;',
  116. "\xE1" => '&#945;',
  117. "\xE2" => '&#946;',
  118. "\xE3" => '&#947;',
  119. "\xE4" => '&#948;',
  120. "\xE5" => '&#949;',
  121. "\xE6" => '&#950;',
  122. "\xE7" => '&#951;',
  123. "\xE8" => '&#952;',
  124. "\xE9" => '&#953;',
  125. "\xEA" => '&#954;',
  126. "\xEB" => '&#955;',
  127. "\xEC" => '&#956;',
  128. "\xED" => '&#957;',
  129. "\xEE" => '&#958;',
  130. "\xEF" => '&#959;',
  131. "\xF0" => '&#960;',
  132. "\xF1" => '&#961;',
  133. "\xF2" => '&#962;',
  134. "\xF3" => '&#963;',
  135. "\xF4" => '&#964;',
  136. "\xF5" => '&#965;',
  137. "\xF6" => '&#966;',
  138. "\xF7" => '&#967;',
  139. "\xF8" => '&#968;',
  140. "\xF9" => '&#969;',
  141. "\xFA" => '&#970;',
  142. "\xFB" => '&#971;',
  143. "\xFC" => '&#972;',
  144. "\xFD" => '&#973;',
  145. "\xFE" => '&#974;'
  146. );
  147. $string = str_replace(array_keys($iso8859_7), array_values($iso8859_7), $string);
  148. return $string;
  149. }
  150. ?>