iso8859-7.php 3.7 KB

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