/gui/tools/webmail/functions/decode/cp1253.php

https://github.com/BenBE/ispCP · PHP · 171 lines · 137 code · 6 blank · 28 comment · 1 complexity · 5a5d5fa5e88760c4a2c5fe52cdad2253 MD5 · raw file

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