iso_8859_5.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. /**
  3. * decode/iso8859-5.php
  4. *
  5. * This file contains iso-8859-5 decoding function that is needed to read
  6. * iso-8859-5 encoded mails in non-iso-8859-5 locale.
  7. *
  8. * Original data taken from:
  9. * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-5.TXT
  10. *
  11. * Name: ISO 8859-5: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-5 encoded string
  43. * @param string $string Encoded string
  44. * @return string $string Decoded string
  45. */
  46. function charset_decode_iso_8859_5 ($string) {
  47. // don't do decoding when there are no 8bit symbols
  48. if (! sq_is8bit($string,'iso-8859-5'))
  49. return $string;
  50. $iso8859_5 = array(
  51. "\xA0" => '&#160;',
  52. "\xA1" => '&#1025;',
  53. "\xA2" => '&#1026;',
  54. "\xA3" => '&#1027;',
  55. "\xA4" => '&#1028;',
  56. "\xA5" => '&#1029;',
  57. "\xA6" => '&#1030;',
  58. "\xA7" => '&#1031;',
  59. "\xA8" => '&#1032;',
  60. "\xA9" => '&#1033;',
  61. "\xAA" => '&#1034;',
  62. "\xAB" => '&#1035;',
  63. "\xAC" => '&#1036;',
  64. "\xAD" => '&#173;',
  65. "\xAE" => '&#1038;',
  66. "\xAF" => '&#1039;',
  67. "\xB0" => '&#1040;',
  68. "\xB1" => '&#1041;',
  69. "\xB2" => '&#1042;',
  70. "\xB3" => '&#1043;',
  71. "\xB4" => '&#1044;',
  72. "\xB5" => '&#1045;',
  73. "\xB6" => '&#1046;',
  74. "\xB7" => '&#1047;',
  75. "\xB8" => '&#1048;',
  76. "\xB9" => '&#1049;',
  77. "\xBA" => '&#1050;',
  78. "\xBB" => '&#1051;',
  79. "\xBC" => '&#1052;',
  80. "\xBD" => '&#1053;',
  81. "\xBE" => '&#1054;',
  82. "\xBF" => '&#1055;',
  83. "\xC0" => '&#1056;',
  84. "\xC1" => '&#1057;',
  85. "\xC2" => '&#1058;',
  86. "\xC3" => '&#1059;',
  87. "\xC4" => '&#1060;',
  88. "\xC5" => '&#1061;',
  89. "\xC6" => '&#1062;',
  90. "\xC7" => '&#1063;',
  91. "\xC8" => '&#1064;',
  92. "\xC9" => '&#1065;',
  93. "\xCA" => '&#1066;',
  94. "\xCB" => '&#1067;',
  95. "\xCC" => '&#1068;',
  96. "\xCD" => '&#1069;',
  97. "\xCE" => '&#1070;',
  98. "\xCF" => '&#1071;',
  99. "\xD0" => '&#1072;',
  100. "\xD1" => '&#1073;',
  101. "\xD2" => '&#1074;',
  102. "\xD3" => '&#1075;',
  103. "\xD4" => '&#1076;',
  104. "\xD5" => '&#1077;',
  105. "\xD6" => '&#1078;',
  106. "\xD7" => '&#1079;',
  107. "\xD8" => '&#1080;',
  108. "\xD9" => '&#1081;',
  109. "\xDA" => '&#1082;',
  110. "\xDB" => '&#1083;',
  111. "\xDC" => '&#1084;',
  112. "\xDD" => '&#1085;',
  113. "\xDE" => '&#1086;',
  114. "\xDF" => '&#1087;',
  115. "\xE0" => '&#1088;',
  116. "\xE1" => '&#1089;',
  117. "\xE2" => '&#1090;',
  118. "\xE3" => '&#1091;',
  119. "\xE4" => '&#1092;',
  120. "\xE5" => '&#1093;',
  121. "\xE6" => '&#1094;',
  122. "\xE7" => '&#1095;',
  123. "\xE8" => '&#1096;',
  124. "\xE9" => '&#1097;',
  125. "\xEA" => '&#1098;',
  126. "\xEB" => '&#1099;',
  127. "\xEC" => '&#1100;',
  128. "\xED" => '&#1101;',
  129. "\xEE" => '&#1102;',
  130. "\xEF" => '&#1103;',
  131. "\xF0" => '&#8470;',
  132. "\xF1" => '&#1105;',
  133. "\xF2" => '&#1106;',
  134. "\xF3" => '&#1107;',
  135. "\xF4" => '&#1108;',
  136. "\xF5" => '&#1109;',
  137. "\xF6" => '&#1110;',
  138. "\xF7" => '&#1111;',
  139. "\xF8" => '&#1112;',
  140. "\xF9" => '&#1113;',
  141. "\xFA" => '&#1114;',
  142. "\xFB" => '&#1115;',
  143. "\xFC" => '&#1116;',
  144. "\xFD" => '&#167;',
  145. "\xFE" => '&#1118;',
  146. "\xFF" => '&#1119;'
  147. );
  148. $string = str_replace(array_keys($iso8859_5), array_values($iso8859_5), $string);
  149. return $string;
  150. }