iso_8859_2.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. /**
  3. * decode/iso8859-2.php
  4. *
  5. * This file contains iso-8859-2 decoding function that is needed to read
  6. * iso-8859-2 encoded mails in non-iso-8859-2 locale.
  7. *
  8. * Original data taken from:
  9. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-2.TXT
  10. *
  11. * Name: ISO 8859-2:1999 to Unicode
  12. * Unicode version: 3.0
  13. * Table version: 1.0
  14. * Table format: Format A
  15. * Date: 1999 July 27
  16. * Authors: Ken Whistler <kenw@sybase.com>
  17. *
  18. * Original copyright:
  19. * Copyright (c) 1999 Unicode, Inc. All Rights reserved.
  20. *
  21. * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
  22. * No claims are made as to fitness for any particular purpose. No
  23. * warranties of any kind are expressed or implied. The recipient
  24. * agrees to determine applicability of information provided. If this
  25. * file has been provided on optical media by Unicode, Inc., the sole
  26. * remedy for any claim will be exchange of defective media within 90
  27. * days of receipt.
  28. *
  29. * Unicode, Inc. hereby grants the right to freely use the information
  30. * supplied in this file in the creation of products supporting the
  31. * Unicode Standard, and to make copies of this file in any form for
  32. * internal or external distribution as long as this notice remains
  33. * attached.
  34. *
  35. * @copyright &copy; 2003-2006 The SquirrelMail Project Team
  36. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  37. * @version $Id$
  38. * @package squirrelmail
  39. * @subpackage decode
  40. */
  41. /**
  42. * Decode iso8859-2 encoded string
  43. * @param string $string Encoded string
  44. * @return string $string Decoded string
  45. */
  46. function charset_decode_iso_8859_2 ($string) {
  47. // don't do decoding when there are no 8bit symbols
  48. if (! sq_is8bit($string,'iso-8859-2'))
  49. return $string;
  50. $iso8859_2 = array(
  51. "\xA0" => '&#160;',
  52. "\xA1" => '&#260;',
  53. "\xA2" => '&#728;',
  54. "\xA3" => '&#321;',
  55. "\xA4" => '&#164;',
  56. "\xA5" => '&#317;',
  57. "\xA6" => '&#346;',
  58. "\xA7" => '&#167;',
  59. "\xA8" => '&#168;',
  60. "\xA9" => '&#352;',
  61. "\xAA" => '&#350;',
  62. "\xAB" => '&#356;',
  63. "\xAC" => '&#377;',
  64. "\xAD" => '&#173;',
  65. "\xAE" => '&#381;',
  66. "\xAF" => '&#379;',
  67. "\xB0" => '&#176;',
  68. "\xB1" => '&#261;',
  69. "\xB2" => '&#731;',
  70. "\xB3" => '&#322;',
  71. "\xB4" => '&#180;',
  72. "\xB5" => '&#318;',
  73. "\xB6" => '&#347;',
  74. "\xB7" => '&#711;',
  75. "\xB8" => '&#184;',
  76. "\xB9" => '&#353;',
  77. "\xBA" => '&#351;',
  78. "\xBB" => '&#357;',
  79. "\xBC" => '&#378;',
  80. "\xBD" => '&#733;',
  81. "\xBE" => '&#382;',
  82. "\xBF" => '&#380;',
  83. "\xC0" => '&#340;',
  84. "\xC1" => '&#193;',
  85. "\xC2" => '&#194;',
  86. "\xC3" => '&#258;',
  87. "\xC4" => '&#196;',
  88. "\xC5" => '&#313;',
  89. "\xC6" => '&#262;',
  90. "\xC7" => '&#199;',
  91. "\xC8" => '&#268;',
  92. "\xC9" => '&#201;',
  93. "\xCA" => '&#280;',
  94. "\xCB" => '&#203;',
  95. "\xCC" => '&#282;',
  96. "\xCD" => '&#205;',
  97. "\xCE" => '&#206;',
  98. "\xCF" => '&#270;',
  99. "\xD0" => '&#272;',
  100. "\xD1" => '&#323;',
  101. "\xD2" => '&#327;',
  102. "\xD3" => '&#211;',
  103. "\xD4" => '&#212;',
  104. "\xD5" => '&#336;',
  105. "\xD6" => '&#214;',
  106. "\xD7" => '&#215;',
  107. "\xD8" => '&#344;',
  108. "\xD9" => '&#366;',
  109. "\xDA" => '&#218;',
  110. "\xDB" => '&#368;',
  111. "\xDC" => '&#220;',
  112. "\xDD" => '&#221;',
  113. "\xDE" => '&#354;',
  114. "\xDF" => '&#223;',
  115. "\xE0" => '&#341;',
  116. "\xE1" => '&#225;',
  117. "\xE2" => '&#226;',
  118. "\xE3" => '&#259;',
  119. "\xE4" => '&#228;',
  120. "\xE5" => '&#314;',
  121. "\xE6" => '&#263;',
  122. "\xE7" => '&#231;',
  123. "\xE8" => '&#269;',
  124. "\xE9" => '&#233;',
  125. "\xEA" => '&#281;',
  126. "\xEB" => '&#235;',
  127. "\xEC" => '&#283;',
  128. "\xED" => '&#237;',
  129. "\xEE" => '&#238;',
  130. "\xEF" => '&#271;',
  131. "\xF0" => '&#273;',
  132. "\xF1" => '&#324;',
  133. "\xF2" => '&#328;',
  134. "\xF3" => '&#243;',
  135. "\xF4" => '&#244;',
  136. "\xF5" => '&#337;',
  137. "\xF6" => '&#246;',
  138. "\xF7" => '&#247;',
  139. "\xF8" => '&#345;',
  140. "\xF9" => '&#367;',
  141. "\xFA" => '&#250;',
  142. "\xFB" => '&#369;',
  143. "\xFC" => '&#252;',
  144. "\xFD" => '&#253;',
  145. "\xFE" => '&#355;',
  146. "\xFF" => '&#729;'
  147. );
  148. $string = str_replace(array_keys($iso8859_2), array_values($iso8859_2), $string);
  149. return $string;
  150. }