iso_8859_3.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /**
  3. * decode/iso8859-3.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-3 decoding function that is needed to read
  9. * iso-8859-3 encoded mails in non-iso-8859-3 locale.
  10. *
  11. * Original data taken from:
  12. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-3.TXT
  13. *
  14. * Name: ISO/IEC 8859-3:1999 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-3 encoded string
  44. * @param string $string Encoded string
  45. * @return string $string Decoded string
  46. */
  47. function charset_decode_iso_8859_3 ($string) {
  48. global $default_charset;
  49. if (strtolower($default_charset) == 'iso-8859-3')
  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_3 = array(
  56. "\xA0" => '&#160;',
  57. "\xA1" => '&#294;',
  58. "\xA2" => '&#728;',
  59. "\xA3" => '&#163;',
  60. "\xA4" => '&#164;',
  61. "\xA6" => '&#292;',
  62. "\xA7" => '&#167;',
  63. "\xA8" => '&#168;',
  64. "\xA9" => '&#304;',
  65. "\xAA" => '&#350;',
  66. "\xAB" => '&#286;',
  67. "\xAC" => '&#308;',
  68. "\xAD" => '&#173;',
  69. "\xAF" => '&#379;',
  70. "\xB0" => '&#176;',
  71. "\xB1" => '&#295;',
  72. "\xB2" => '&#178;',
  73. "\xB3" => '&#179;',
  74. "\xB4" => '&#180;',
  75. "\xB5" => '&#181;',
  76. "\xB6" => '&#293;',
  77. "\xB7" => '&#183;',
  78. "\xB8" => '&#184;',
  79. "\xB9" => '&#305;',
  80. "\xBA" => '&#351;',
  81. "\xBB" => '&#287;',
  82. "\xBC" => '&#309;',
  83. "\xBD" => '&#189;',
  84. "\xBF" => '&#380;',
  85. "\xC0" => '&#192;',
  86. "\xC1" => '&#193;',
  87. "\xC2" => '&#194;',
  88. "\xC4" => '&#196;',
  89. "\xC5" => '&#266;',
  90. "\xC6" => '&#264;',
  91. "\xC7" => '&#199;',
  92. "\xC8" => '&#200;',
  93. "\xC9" => '&#201;',
  94. "\xCA" => '&#202;',
  95. "\xCB" => '&#203;',
  96. "\xCC" => '&#204;',
  97. "\xCD" => '&#205;',
  98. "\xCE" => '&#206;',
  99. "\xCF" => '&#207;',
  100. "\xD1" => '&#209;',
  101. "\xD2" => '&#210;',
  102. "\xD3" => '&#211;',
  103. "\xD4" => '&#212;',
  104. "\xD5" => '&#288;',
  105. "\xD6" => '&#214;',
  106. "\xD7" => '&#215;',
  107. "\xD8" => '&#284;',
  108. "\xD9" => '&#217;',
  109. "\xDA" => '&#218;',
  110. "\xDB" => '&#219;',
  111. "\xDC" => '&#220;',
  112. "\xDD" => '&#364;',
  113. "\xDE" => '&#348;',
  114. "\xDF" => '&#223;',
  115. "\xE0" => '&#224;',
  116. "\xE1" => '&#225;',
  117. "\xE2" => '&#226;',
  118. "\xE4" => '&#228;',
  119. "\xE5" => '&#267;',
  120. "\xE6" => '&#265;',
  121. "\xE7" => '&#231;',
  122. "\xE8" => '&#232;',
  123. "\xE9" => '&#233;',
  124. "\xEA" => '&#234;',
  125. "\xEB" => '&#235;',
  126. "\xEC" => '&#236;',
  127. "\xED" => '&#237;',
  128. "\xEE" => '&#238;',
  129. "\xEF" => '&#239;',
  130. "\xF1" => '&#241;',
  131. "\xF2" => '&#242;',
  132. "\xF3" => '&#243;',
  133. "\xF4" => '&#244;',
  134. "\xF5" => '&#289;',
  135. "\xF6" => '&#246;',
  136. "\xF7" => '&#247;',
  137. "\xF8" => '&#285;',
  138. "\xF9" => '&#249;',
  139. "\xFA" => '&#250;',
  140. "\xFB" => '&#251;',
  141. "\xFC" => '&#252;',
  142. "\xFD" => '&#365;',
  143. "\xFE" => '&#349;',
  144. "\xFF" => '&#729;'
  145. );
  146. $string = str_replace(array_keys($iso8859_3), array_values($iso8859_3), $string);
  147. return $string;
  148. }
  149. ?>