iso8859-2.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. /*
  3. * decode/iso8859-2.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-2 decoding function that is needed to read
  10. * iso-8859-2 encoded mails in non-iso-8859-2 locale.
  11. *
  12. * Original data taken from:
  13. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-2.TXT
  14. *
  15. * Name: ISO 8859-2: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_2 ($string) {
  41. global $default_charset;
  42. if (strtolower($default_charset) == 'iso-8859-2')
  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_2 = array(
  49. "\xA0" => '&#160;',
  50. "\xA1" => '&#260;',
  51. "\xA2" => '&#728;',
  52. "\xA3" => '&#321;',
  53. "\xA4" => '&#164;',
  54. "\xA5" => '&#317;',
  55. "\xA6" => '&#346;',
  56. "\xA7" => '&#167;',
  57. "\xA8" => '&#168;',
  58. "\xA9" => '&#352;',
  59. "\xAA" => '&#350;',
  60. "\xAB" => '&#356;',
  61. "\xAC" => '&#377;',
  62. "\xAD" => '&#173;',
  63. "\xAE" => '&#381;',
  64. "\xAF" => '&#379;',
  65. "\xB0" => '&#176;',
  66. "\xB1" => '&#261;',
  67. "\xB2" => '&#731;',
  68. "\xB3" => '&#322;',
  69. "\xB4" => '&#180;',
  70. "\xB5" => '&#318;',
  71. "\xB6" => '&#347;',
  72. "\xB7" => '&#711;',
  73. "\xB8" => '&#184;',
  74. "\xB9" => '&#353;',
  75. "\xBA" => '&#351;',
  76. "\xBB" => '&#357;',
  77. "\xBC" => '&#378;',
  78. "\xBD" => '&#733;',
  79. "\xBE" => '&#382;',
  80. "\xBF" => '&#380;',
  81. "\xC0" => '&#340;',
  82. "\xC1" => '&#193;',
  83. "\xC2" => '&#194;',
  84. "\xC3" => '&#258;',
  85. "\xC4" => '&#196;',
  86. "\xC5" => '&#313;',
  87. "\xC6" => '&#262;',
  88. "\xC7" => '&#199;',
  89. "\xC8" => '&#268;',
  90. "\xC9" => '&#201;',
  91. "\xCA" => '&#280;',
  92. "\xCB" => '&#203;',
  93. "\xCC" => '&#282;',
  94. "\xCD" => '&#205;',
  95. "\xCE" => '&#206;',
  96. "\xCF" => '&#270;',
  97. "\xD0" => '&#272;',
  98. "\xD1" => '&#323;',
  99. "\xD2" => '&#327;',
  100. "\xD3" => '&#211;',
  101. "\xD4" => '&#212;',
  102. "\xD5" => '&#336;',
  103. "\xD6" => '&#214;',
  104. "\xD7" => '&#215;',
  105. "\xD8" => '&#344;',
  106. "\xD9" => '&#366;',
  107. "\xDA" => '&#218;',
  108. "\xDB" => '&#368;',
  109. "\xDC" => '&#220;',
  110. "\xDD" => '&#221;',
  111. "\xDE" => '&#354;',
  112. "\xDF" => '&#223;',
  113. "\xE0" => '&#341;',
  114. "\xE1" => '&#225;',
  115. "\xE2" => '&#226;',
  116. "\xE3" => '&#259;',
  117. "\xE4" => '&#228;',
  118. "\xE5" => '&#314;',
  119. "\xE6" => '&#263;',
  120. "\xE7" => '&#231;',
  121. "\xE8" => '&#269;',
  122. "\xE9" => '&#233;',
  123. "\xEA" => '&#281;',
  124. "\xEB" => '&#235;',
  125. "\xEC" => '&#283;',
  126. "\xED" => '&#237;',
  127. "\xEE" => '&#238;',
  128. "\xEF" => '&#271;',
  129. "\xF0" => '&#273;',
  130. "\xF1" => '&#324;',
  131. "\xF2" => '&#328;',
  132. "\xF3" => '&#243;',
  133. "\xF4" => '&#244;',
  134. "\xF5" => '&#337;',
  135. "\xF6" => '&#246;',
  136. "\xF7" => '&#247;',
  137. "\xF8" => '&#345;',
  138. "\xF9" => '&#367;',
  139. "\xFA" => '&#250;',
  140. "\xFB" => '&#369;',
  141. "\xFC" => '&#252;',
  142. "\xFD" => '&#253;',
  143. "\xFE" => '&#355;',
  144. "\xFF" => '&#729;'
  145. );
  146. $string = str_replace(array_keys($iso8859_2), array_values($iso8859_2), $string);
  147. return $string;
  148. }
  149. ?>