iso8859-3.php 3.7 KB

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