iso_8859_16.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. /**
  3. * decode/iso8859-16.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-16 decoding function that is needed to read
  9. * iso-8859-16 encoded mails in non-iso-8859-16 locale.
  10. *
  11. * Original data taken from:
  12. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-16.TXT
  13. *
  14. * Name: ISO/IEC 8859-16:2001 to Unicode
  15. * Unicode version: 3.0
  16. * Table version: 1.0
  17. * Table format: Format A
  18. * Date: 2001 July 26
  19. * Authors: Markus Kuhn <mkuhn@acm.org>
  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-16 string
  44. * @param string $string Encoded string
  45. * @return string $string Decoded string
  46. */
  47. function charset_decode_iso_8859_16 ($string) {
  48. global $default_charset;
  49. if (strtolower($default_charset) == 'iso-8859-16')
  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. $iso8869_16 = array(
  56. "\xA0" => '&#160;',
  57. "\xA1" => '&#260;',
  58. "\xA2" => '&#261;',
  59. "\xA3" => '&#321;',
  60. "\xA4" => '&#8364;',
  61. "\xA5" => '&#8222;',
  62. "\xA6" => '&#352;',
  63. "\xA7" => '&#167;',
  64. "\xA8" => '&#353;',
  65. "\xA9" => '&#169;',
  66. "\xAA" => '&#536;',
  67. "\xAB" => '&#171;',
  68. "\xAC" => '&#377;',
  69. "\xAD" => '&#173;',
  70. "\xAE" => '&#378;',
  71. "\xAF" => '&#379;',
  72. "\xB0" => '&#176;',
  73. "\xB1" => '&#177;',
  74. "\xB2" => '&#268;',
  75. "\xB3" => '&#322;',
  76. "\xB4" => '&#381;',
  77. "\xB5" => '&#8221;',
  78. "\xB6" => '&#182;',
  79. "\xB7" => '&#183;',
  80. "\xB8" => '&#382;',
  81. "\xB9" => '&#269;',
  82. "\xBA" => '&#537;',
  83. "\xBB" => '&#187;',
  84. "\xBC" => '&#338;',
  85. "\xBD" => '&#339;',
  86. "\xBE" => '&#376;',
  87. "\xBF" => '&#380;',
  88. "\xC0" => '&#192;',
  89. "\xC1" => '&#193;',
  90. "\xC2" => '&#194;',
  91. "\xC3" => '&#258;',
  92. "\xC4" => '&#196;',
  93. "\xC5" => '&#262;',
  94. "\xC6" => '&#198;',
  95. "\xC7" => '&#199;',
  96. "\xC8" => '&#200;',
  97. "\xC9" => '&#201;',
  98. "\xCA" => '&#202;',
  99. "\xCB" => '&#203;',
  100. "\xCC" => '&#204;',
  101. "\xCD" => '&#205;',
  102. "\xCE" => '&#206;',
  103. "\xCF" => '&#207;',
  104. "\xD0" => '&#272;',
  105. "\xD1" => '&#323;',
  106. "\xD2" => '&#210;',
  107. "\xD3" => '&#211;',
  108. "\xD4" => '&#212;',
  109. "\xD5" => '&#336;',
  110. "\xD6" => '&#214;',
  111. "\xD7" => '&#346;',
  112. "\xD8" => '&#368;',
  113. "\xD9" => '&#217;',
  114. "\xDA" => '&#218;',
  115. "\xDB" => '&#219;',
  116. "\xDC" => '&#220;',
  117. "\xDD" => '&#280;',
  118. "\xDE" => '&#538;',
  119. "\xDF" => '&#223;',
  120. "\xE0" => '&#224;',
  121. "\xE1" => '&#225;',
  122. "\xE2" => '&#226;',
  123. "\xE3" => '&#259;',
  124. "\xE4" => '&#228;',
  125. "\xE5" => '&#263;',
  126. "\xE6" => '&#230;',
  127. "\xE7" => '&#231;',
  128. "\xE8" => '&#232;',
  129. "\xE9" => '&#233;',
  130. "\xEA" => '&#234;',
  131. "\xEB" => '&#235;',
  132. "\xEC" => '&#236;',
  133. "\xED" => '&#237;',
  134. "\xEE" => '&#238;',
  135. "\xEF" => '&#239;',
  136. "\xF0" => '&#273;',
  137. "\xF1" => '&#324;',
  138. "\xF2" => '&#242;',
  139. "\xF3" => '&#243;',
  140. "\xF4" => '&#244;',
  141. "\xF5" => '&#337;',
  142. "\xF6" => '&#246;',
  143. "\xF7" => '&#347;',
  144. "\xF8" => '&#369;',
  145. "\xF9" => '&#249;',
  146. "\xFA" => '&#250;',
  147. "\xFB" => '&#251;',
  148. "\xFC" => '&#252;',
  149. "\xFD" => '&#281;',
  150. "\xFE" => '&#539;',
  151. "\xFF" => '&#255;'
  152. );
  153. $string = str_replace(array_keys($iso8859_16), array_values($iso8859_16), $string);
  154. return $string;
  155. }
  156. ?>