iso_8859_5.php 4.1 KB

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