iso8859-5.php 3.9 KB

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