cp1253.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. /**
  3. * decode/cp1253.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 cp1253 decoding function that is needed to read
  9. * cp1253 encoded mails in non-cp1253 locale.
  10. *
  11. * Original data taken from:
  12. * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1253.TXT
  13. *
  14. * Name: cp1253 to Unicode table
  15. * Unicode version: 2.0
  16. * Table version: 2.01
  17. * Table format: Format A
  18. * Date: 04/15/98
  19. * Contact: cpxlate@microsoft.com
  20. *
  21. * @version $Id$
  22. * @package squirrelmail
  23. * @subpackage decode
  24. */
  25. /**
  26. * Decode cp1253-encoded string
  27. * @param string $string Encoded string
  28. * @return string $string Decoded string
  29. */
  30. function charset_decode_cp1253 ($string) {
  31. global $default_charset;
  32. if (strtolower($default_charset) == 'windows-1253')
  33. return $string;
  34. /* Only do the slow convert if there are 8-bit characters */
  35. /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
  36. if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
  37. return $string;
  38. $cp1253 = array(
  39. "\x80" => '&#8364;',
  40. "\x81" => '&#65533;',
  41. "\x82" => '&#8218;',
  42. "\x83" => '&#402;',
  43. "\x84" => '&#8222;',
  44. "\x85" => '&#8230;',
  45. "\x86" => '&#8224;',
  46. "\x87" => '&#8225;',
  47. "\x88" => '&#65533;',
  48. "\x89" => '&#8240;',
  49. "\x8A" => '&#65533;',
  50. "\x8B" => '&#8249;',
  51. "\x8C" => '&#65533;',
  52. "\x8D" => '&#65533;',
  53. "\x8E" => '&#65533;',
  54. "\x8F" => '&#65533;',
  55. "\x90" => '&#65533;',
  56. "\x91" => '&#8216;',
  57. "\x92" => '&#8217;',
  58. "\x93" => '&#8220;',
  59. "\x94" => '&#8221;',
  60. "\x95" => '&#8226;',
  61. "\x96" => '&#8211;',
  62. "\x97" => '&#8212;',
  63. "\x98" => '&#65533;',
  64. "\x99" => '&#8482;',
  65. "\x9A" => '&#65533;',
  66. "\x9B" => '&#8250;',
  67. "\x9C" => '&#65533;',
  68. "\x9D" => '&#65533;',
  69. "\x9E" => '&#65533;',
  70. "\x9F" => '&#65533;',
  71. "\xA0" => '&#160;',
  72. "\xA1" => '&#901;',
  73. "\xA2" => '&#902;',
  74. "\xA3" => '&#163;',
  75. "\xA4" => '&#164;',
  76. "\xA5" => '&#165;',
  77. "\xA6" => '&#166;',
  78. "\xA7" => '&#167;',
  79. "\xA8" => '&#168;',
  80. "\xA9" => '&#169;',
  81. "\xAA" => '&#65533;',
  82. "\xAB" => '&#171;',
  83. "\xAC" => '&#172;',
  84. "\xAD" => '&#173;',
  85. "\xAE" => '&#174;',
  86. "\xAF" => '&#8213;',
  87. "\xB0" => '&#176;',
  88. "\xB1" => '&#177;',
  89. "\xB2" => '&#178;',
  90. "\xB3" => '&#179;',
  91. "\xB4" => '&#900;',
  92. "\xB5" => '&#181;',
  93. "\xB6" => '&#182;',
  94. "\xB7" => '&#183;',
  95. "\xB8" => '&#904;',
  96. "\xB9" => '&#905;',
  97. "\xBA" => '&#906;',
  98. "\xBB" => '&#187;',
  99. "\xBC" => '&#908;',
  100. "\xBD" => '&#189;',
  101. "\xBE" => '&#910;',
  102. "\xBF" => '&#911;',
  103. "\xC0" => '&#912;',
  104. "\xC1" => '&#913;',
  105. "\xC2" => '&#914;',
  106. "\xC3" => '&#915;',
  107. "\xC4" => '&#916;',
  108. "\xC5" => '&#917;',
  109. "\xC6" => '&#918;',
  110. "\xC7" => '&#919;',
  111. "\xC8" => '&#920;',
  112. "\xC9" => '&#921;',
  113. "\xCA" => '&#922;',
  114. "\xCB" => '&#923;',
  115. "\xCC" => '&#924;',
  116. "\xCD" => '&#925;',
  117. "\xCE" => '&#926;',
  118. "\xCF" => '&#927;',
  119. "\xD0" => '&#928;',
  120. "\xD1" => '&#929;',
  121. "\xD2" => '&#65533;',
  122. "\xD3" => '&#931;',
  123. "\xD4" => '&#932;',
  124. "\xD5" => '&#933;',
  125. "\xD6" => '&#934;',
  126. "\xD7" => '&#935;',
  127. "\xD8" => '&#936;',
  128. "\xD9" => '&#937;',
  129. "\xDA" => '&#938;',
  130. "\xDB" => '&#939;',
  131. "\xDC" => '&#940;',
  132. "\xDD" => '&#941;',
  133. "\xDE" => '&#942;',
  134. "\xDF" => '&#943;',
  135. "\xE0" => '&#944;',
  136. "\xE1" => '&#945;',
  137. "\xE2" => '&#946;',
  138. "\xE3" => '&#947;',
  139. "\xE4" => '&#948;',
  140. "\xE5" => '&#949;',
  141. "\xE6" => '&#950;',
  142. "\xE7" => '&#951;',
  143. "\xE8" => '&#952;',
  144. "\xE9" => '&#953;',
  145. "\xEA" => '&#954;',
  146. "\xEB" => '&#955;',
  147. "\xEC" => '&#956;',
  148. "\xED" => '&#957;',
  149. "\xEE" => '&#958;',
  150. "\xEF" => '&#959;',
  151. "\xF0" => '&#960;',
  152. "\xF1" => '&#961;',
  153. "\xF2" => '&#962;',
  154. "\xF3" => '&#963;',
  155. "\xF4" => '&#964;',
  156. "\xF5" => '&#965;',
  157. "\xF6" => '&#966;',
  158. "\xF7" => '&#967;',
  159. "\xF8" => '&#968;',
  160. "\xF9" => '&#969;',
  161. "\xFA" => '&#970;',
  162. "\xFB" => '&#971;',
  163. "\xFC" => '&#972;',
  164. "\xFD" => '&#973;',
  165. "\xFE" => '&#974;',
  166. "\xFF" => '&#65533;'
  167. );
  168. $string = str_replace(array_keys($cp1253), array_values($cp1253), $string);
  169. return $string;
  170. }
  171. ?>