iso8859-15.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /*
  3. * decode/iso8859-15.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-15 decoding function that is needed to read
  10. * iso-8859-15 encoded mails in non-iso-8859-15 locale.
  11. *
  12. * Original data taken from:
  13. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-15.TXT
  14. *
  15. * Name: ISO/IEC 8859-15: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: Markus Kuhn <mkuhn@acm.org>
  21. * Ken Whistler <kenw@sybase.com>
  22. *
  23. * Original copyright:
  24. * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
  25. *
  26. * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
  27. * No claims are made as to fitness for any particular purpose. No
  28. * warranties of any kind are expressed or implied. The recipient
  29. * agrees to determine applicability of information provided. If this
  30. * file has been provided on optical media by Unicode, Inc., the sole
  31. * remedy for any claim will be exchange of defective media within 90
  32. * days of receipt.
  33. *
  34. * Unicode, Inc. hereby grants the right to freely use the information
  35. * supplied in this file in the creation of products supporting the
  36. * Unicode Standard, and to make copies of this file in any form for
  37. * internal or external distribution as long as this notice remains
  38. * attached.
  39. *
  40. */
  41. function charset_decode_iso8859_15 ($string) {
  42. global $default_charset;
  43. if (strtolower($default_charset) == 'iso-8859-15')
  44. return $string;
  45. /* Only do the slow convert if there are 8-bit characters */
  46. /* there is no 0x80-0x9F letters in ISO8859-* */
  47. if ( ! ereg("[\241-\377]", $string) )
  48. return $string;
  49. $iso8859_15 = array(
  50. "\xA0" => '&#160;',
  51. "\xA1" => '&#161;',
  52. "\xA2" => '&#162;',
  53. "\xA3" => '&#163;',
  54. "\xA4" => '&#8364;',
  55. "\xA5" => '&#165;',
  56. "\xA6" => '&#352;',
  57. "\xA7" => '&#167;',
  58. "\xA8" => '&#353;',
  59. "\xA9" => '&#169;',
  60. "\xAA" => '&#170;',
  61. "\xAB" => '&#171;',
  62. "\xAC" => '&#172;',
  63. "\xAD" => '&#173;',
  64. "\xAE" => '&#174;',
  65. "\xAF" => '&#175;',
  66. "\xB0" => '&#176;',
  67. "\xB1" => '&#177;',
  68. "\xB2" => '&#178;',
  69. "\xB3" => '&#179;',
  70. "\xB4" => '&#381;',
  71. "\xB5" => '&#181;',
  72. "\xB6" => '&#182;',
  73. "\xB7" => '&#183;',
  74. "\xB8" => '&#382;',
  75. "\xB9" => '&#185;',
  76. "\xBA" => '&#186;',
  77. "\xBB" => '&#187;',
  78. "\xBC" => '&#338;',
  79. "\xBD" => '&#339;',
  80. "\xBE" => '&#376;',
  81. "\xBF" => '&#191;',
  82. "\xC0" => '&#192;',
  83. "\xC1" => '&#193;',
  84. "\xC2" => '&#194;',
  85. "\xC3" => '&#195;',
  86. "\xC4" => '&#196;',
  87. "\xC5" => '&#197;',
  88. "\xC6" => '&#198;',
  89. "\xC7" => '&#199;',
  90. "\xC8" => '&#200;',
  91. "\xC9" => '&#201;',
  92. "\xCA" => '&#202;',
  93. "\xCB" => '&#203;',
  94. "\xCC" => '&#204;',
  95. "\xCD" => '&#205;',
  96. "\xCE" => '&#206;',
  97. "\xCF" => '&#207;',
  98. "\xD0" => '&#208;',
  99. "\xD1" => '&#209;',
  100. "\xD2" => '&#210;',
  101. "\xD3" => '&#211;',
  102. "\xD4" => '&#212;',
  103. "\xD5" => '&#213;',
  104. "\xD6" => '&#214;',
  105. "\xD7" => '&#215;',
  106. "\xD8" => '&#216;',
  107. "\xD9" => '&#217;',
  108. "\xDA" => '&#218;',
  109. "\xDB" => '&#219;',
  110. "\xDC" => '&#220;',
  111. "\xDD" => '&#221;',
  112. "\xDE" => '&#222;',
  113. "\xDF" => '&#223;',
  114. "\xE0" => '&#224;',
  115. "\xE1" => '&#225;',
  116. "\xE2" => '&#226;',
  117. "\xE3" => '&#227;',
  118. "\xE4" => '&#228;',
  119. "\xE5" => '&#229;',
  120. "\xE6" => '&#230;',
  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. "\xF0" => '&#240;',
  131. "\xF1" => '&#241;',
  132. "\xF2" => '&#242;',
  133. "\xF3" => '&#243;',
  134. "\xF4" => '&#244;',
  135. "\xF5" => '&#245;',
  136. "\xF6" => '&#246;',
  137. "\xF7" => '&#247;',
  138. "\xF8" => '&#248;',
  139. "\xF9" => '&#249;',
  140. "\xFA" => '&#250;',
  141. "\xFB" => '&#251;',
  142. "\xFC" => '&#252;',
  143. "\xFD" => '&#253;',
  144. "\xFE" => '&#254;',
  145. "\xFF" => '&#255;'
  146. );
  147. $string = str_replace(array_keys($iso8859_15), array_values($iso8859_15), $string);
  148. return $string;
  149. }
  150. ?>