iso_8859_7.php 4.4 KB

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