iso8859-7.php 3.9 KB

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