iso_8859_11.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. /**
  3. * decode/iso8859-11.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-11 decoding function that is needed to read
  9. * iso-8859-11 encoded mails in non-iso-8859-11 locale.
  10. *
  11. * Original data taken from:
  12. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-11.TXT
  13. *
  14. * Name: ISO/IEC 8859-11:2001 to Unicode
  15. * Unicode version: 3.2
  16. * Table version: 1.0
  17. * Table format: Format A
  18. * Date: 2002 October 7
  19. * Authors: Ken Whistler <kenw@sybase.com>
  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-11 string
  44. * @param string $string Encoded string
  45. * @return string $string Decoded string
  46. */
  47. function charset_decode_iso_8859_11 ($string) {
  48. global $default_charset;
  49. if (strtolower($default_charset) == 'iso-8859-11')
  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. $iso8859_11 = array(
  56. "\xA0" => '&#160;',
  57. "\xA1" => '&#3585;',
  58. "\xA2" => '&#3586;',
  59. "\xA3" => '&#3587;',
  60. "\xA4" => '&#3588;',
  61. "\xA5" => '&#3589;',
  62. "\xA6" => '&#3590;',
  63. "\xA7" => '&#3591;',
  64. "\xA8" => '&#3592;',
  65. "\xA9" => '&#3593;',
  66. "\xAA" => '&#3594;',
  67. "\xAB" => '&#3595;',
  68. "\xAC" => '&#3596;',
  69. "\xAD" => '&#3597;',
  70. "\xAE" => '&#3598;',
  71. "\xAF" => '&#3599;',
  72. "\xB0" => '&#3600;',
  73. "\xB1" => '&#3601;',
  74. "\xB2" => '&#3602;',
  75. "\xB3" => '&#3603;',
  76. "\xB4" => '&#3604;',
  77. "\xB5" => '&#3605;',
  78. "\xB6" => '&#3606;',
  79. "\xB7" => '&#3607;',
  80. "\xB8" => '&#3608;',
  81. "\xB9" => '&#3609;',
  82. "\xBA" => '&#3610;',
  83. "\xBB" => '&#3611;',
  84. "\xBC" => '&#3612;',
  85. "\xBD" => '&#3613;',
  86. "\xBE" => '&#3614;',
  87. "\xBF" => '&#3615;',
  88. "\xC0" => '&#3616;',
  89. "\xC1" => '&#3617;',
  90. "\xC2" => '&#3618;',
  91. "\xC3" => '&#3619;',
  92. "\xC4" => '&#3620;',
  93. "\xC5" => '&#3621;',
  94. "\xC6" => '&#3622;',
  95. "\xC7" => '&#3623;',
  96. "\xC8" => '&#3624;',
  97. "\xC9" => '&#3625;',
  98. "\xCA" => '&#3626;',
  99. "\xCB" => '&#3627;',
  100. "\xCC" => '&#3628;',
  101. "\xCD" => '&#3629;',
  102. "\xCE" => '&#3630;',
  103. "\xCF" => '&#3631;',
  104. "\xD0" => '&#3632;',
  105. "\xD1" => '&#3633;',
  106. "\xD2" => '&#3634;',
  107. "\xD3" => '&#3635;',
  108. "\xD4" => '&#3636;',
  109. "\xD5" => '&#3637;',
  110. "\xD6" => '&#3638;',
  111. "\xD7" => '&#3639;',
  112. "\xD8" => '&#3640;',
  113. "\xD9" => '&#3641;',
  114. "\xDA" => '&#3642;',
  115. "\xDF" => '&#3647;',
  116. "\xE0" => '&#3648;',
  117. "\xE1" => '&#3649;',
  118. "\xE2" => '&#3650;',
  119. "\xE3" => '&#3651;',
  120. "\xE4" => '&#3652;',
  121. "\xE5" => '&#3653;',
  122. "\xE6" => '&#3654;',
  123. "\xE7" => '&#3655;',
  124. "\xE8" => '&#3656;',
  125. "\xE9" => '&#3657;',
  126. "\xEA" => '&#3658;',
  127. "\xEB" => '&#3659;',
  128. "\xEC" => '&#3660;',
  129. "\xED" => '&#3661;',
  130. "\xEE" => '&#3662;',
  131. "\xEF" => '&#3663;',
  132. "\xF0" => '&#3664;',
  133. "\xF1" => '&#3665;',
  134. "\xF2" => '&#3666;',
  135. "\xF3" => '&#3667;',
  136. "\xF4" => '&#3668;',
  137. "\xF5" => '&#3669;',
  138. "\xF6" => '&#3670;',
  139. "\xF7" => '&#3671;',
  140. "\xF8" => '&#3672;',
  141. "\xF9" => '&#3673;',
  142. "\xFA" => '&#3674;',
  143. "\xFB" => '&#3675;'
  144. );
  145. $string = str_replace(array_keys($iso8859_11), array_values($iso8859_11), $string);
  146. return $string;
  147. }
  148. ?>