iso_8859_15.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /**
  3. * decode/iso8859-15.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-15 decoding function that is needed to read
  9. * iso-8859-15 encoded mails in non-iso-8859-15 locale.
  10. *
  11. * Original data taken from:
  12. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-15.TXT
  13. *
  14. * Name: ISO/IEC 8859-15: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: Markus Kuhn <mkuhn@acm.org>
  20. * 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. * @version $Id$
  40. * @package squirrelmail
  41. * @subpackage decode
  42. */
  43. /**
  44. * Decode iso8859-15 encoded string
  45. * @param string $string Encoded string
  46. * @return string $string Decoded string
  47. */
  48. function charset_decode_iso_8859_15 ($string) {
  49. global $default_charset;
  50. if (strtolower($default_charset) == 'iso-8859-15')
  51. return $string;
  52. /* Only do the slow convert if there are 8-bit characters */
  53. /* there is no 0x80-0x9F letters in ISO8859-* */
  54. if ( ! ereg("[\241-\377]", $string) )
  55. return $string;
  56. $iso8859_15 = array(
  57. "\xA0" => '&#160;',
  58. "\xA1" => '&#161;',
  59. "\xA2" => '&#162;',
  60. "\xA3" => '&#163;',
  61. "\xA4" => '&#8364;',
  62. "\xA5" => '&#165;',
  63. "\xA6" => '&#352;',
  64. "\xA7" => '&#167;',
  65. "\xA8" => '&#353;',
  66. "\xA9" => '&#169;',
  67. "\xAA" => '&#170;',
  68. "\xAB" => '&#171;',
  69. "\xAC" => '&#172;',
  70. "\xAD" => '&#173;',
  71. "\xAE" => '&#174;',
  72. "\xAF" => '&#175;',
  73. "\xB0" => '&#176;',
  74. "\xB1" => '&#177;',
  75. "\xB2" => '&#178;',
  76. "\xB3" => '&#179;',
  77. "\xB4" => '&#381;',
  78. "\xB5" => '&#181;',
  79. "\xB6" => '&#182;',
  80. "\xB7" => '&#183;',
  81. "\xB8" => '&#382;',
  82. "\xB9" => '&#185;',
  83. "\xBA" => '&#186;',
  84. "\xBB" => '&#187;',
  85. "\xBC" => '&#338;',
  86. "\xBD" => '&#339;',
  87. "\xBE" => '&#376;',
  88. "\xBF" => '&#191;',
  89. "\xC0" => '&#192;',
  90. "\xC1" => '&#193;',
  91. "\xC2" => '&#194;',
  92. "\xC3" => '&#195;',
  93. "\xC4" => '&#196;',
  94. "\xC5" => '&#197;',
  95. "\xC6" => '&#198;',
  96. "\xC7" => '&#199;',
  97. "\xC8" => '&#200;',
  98. "\xC9" => '&#201;',
  99. "\xCA" => '&#202;',
  100. "\xCB" => '&#203;',
  101. "\xCC" => '&#204;',
  102. "\xCD" => '&#205;',
  103. "\xCE" => '&#206;',
  104. "\xCF" => '&#207;',
  105. "\xD0" => '&#208;',
  106. "\xD1" => '&#209;',
  107. "\xD2" => '&#210;',
  108. "\xD3" => '&#211;',
  109. "\xD4" => '&#212;',
  110. "\xD5" => '&#213;',
  111. "\xD6" => '&#214;',
  112. "\xD7" => '&#215;',
  113. "\xD8" => '&#216;',
  114. "\xD9" => '&#217;',
  115. "\xDA" => '&#218;',
  116. "\xDB" => '&#219;',
  117. "\xDC" => '&#220;',
  118. "\xDD" => '&#221;',
  119. "\xDE" => '&#222;',
  120. "\xDF" => '&#223;',
  121. "\xE0" => '&#224;',
  122. "\xE1" => '&#225;',
  123. "\xE2" => '&#226;',
  124. "\xE3" => '&#227;',
  125. "\xE4" => '&#228;',
  126. "\xE5" => '&#229;',
  127. "\xE6" => '&#230;',
  128. "\xE7" => '&#231;',
  129. "\xE8" => '&#232;',
  130. "\xE9" => '&#233;',
  131. "\xEA" => '&#234;',
  132. "\xEB" => '&#235;',
  133. "\xEC" => '&#236;',
  134. "\xED" => '&#237;',
  135. "\xEE" => '&#238;',
  136. "\xEF" => '&#239;',
  137. "\xF0" => '&#240;',
  138. "\xF1" => '&#241;',
  139. "\xF2" => '&#242;',
  140. "\xF3" => '&#243;',
  141. "\xF4" => '&#244;',
  142. "\xF5" => '&#245;',
  143. "\xF6" => '&#246;',
  144. "\xF7" => '&#247;',
  145. "\xF8" => '&#248;',
  146. "\xF9" => '&#249;',
  147. "\xFA" => '&#250;',
  148. "\xFB" => '&#251;',
  149. "\xFC" => '&#252;',
  150. "\xFD" => '&#253;',
  151. "\xFE" => '&#254;',
  152. "\xFF" => '&#255;'
  153. );
  154. $string = str_replace(array_keys($iso8859_15), array_values($iso8859_15), $string);
  155. return $string;
  156. }
  157. ?>