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

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

  1. <?php
  2. /**
  3. * decode/cp1255.php
  4. *
  5. * This file contains cp1255 decoding function that is needed to read
  6. * cp1255 encoded mails in non-cp1255 locale.
  7. *
  8. * Original data taken from:
  9. * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT
  10. *
  11. * Name: cp1255 to Unicode table
  12. * Unicode version: 2.0
  13. * Table version: 2.01
  14. * Table format: Format A
  15. * Date: 1/7/2000
  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: cp1255.php 14084 2011-01-06 02:44:03Z pdontthink $
  21. * @package squirrelmail
  22. * @subpackage decode
  23. */
  24. /**
  25. * Decode cp1255-encoded string
  26. * @param string $string Encoded string
  27. * @return string $string decoded string
  28. */
  29. function charset_decode_cp1255 ($string) {
  30. // don't do decoding when there are no 8bit symbols
  31. if (! sq_is8bit($string,'windows-1255'))
  32. return $string;
  33. $cp1255 = 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" => '&#710;',
  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" => '&#732;',
  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" => '&#161;',
  68. "\xA2" => '&#162;',
  69. "\xA3" => '&#163;',
  70. "\xA4" => '&#8362;',
  71. "\xA5" => '&#165;',
  72. "\xA6" => '&#166;',
  73. "\xA7" => '&#167;',
  74. "\xA8" => '&#168;',
  75. "\xA9" => '&#169;',
  76. "\xAA" => '&#215;',
  77. "\xAB" => '&#171;',
  78. "\xAC" => '&#172;',
  79. "\xAD" => '&#173;',
  80. "\xAE" => '&#174;',
  81. "\xAF" => '&#175;',
  82. "\xB0" => '&#176;',
  83. "\xB1" => '&#177;',
  84. "\xB2" => '&#178;',
  85. "\xB3" => '&#179;',
  86. "\xB4" => '&#180;',
  87. "\xB5" => '&#181;',
  88. "\xB6" => '&#182;',
  89. "\xB7" => '&#183;',
  90. "\xB8" => '&#184;',
  91. "\xB9" => '&#185;',
  92. "\xBA" => '&#247;',
  93. "\xBB" => '&#187;',
  94. "\xBC" => '&#188;',
  95. "\xBD" => '&#189;',
  96. "\xBE" => '&#190;',
  97. "\xBF" => '&#191;',
  98. "\xC0" => '&#1456;',
  99. "\xC1" => '&#1457;',
  100. "\xC2" => '&#1458;',
  101. "\xC3" => '&#1459;',
  102. "\xC4" => '&#1460;',
  103. "\xC5" => '&#1461;',
  104. "\xC6" => '&#1462;',
  105. "\xC7" => '&#1463;',
  106. "\xC8" => '&#1464;',
  107. "\xC9" => '&#1465;',
  108. "\xCA" => '&#65533;',
  109. "\xCB" => '&#1467;',
  110. "\xCC" => '&#1468;',
  111. "\xCD" => '&#1469;',
  112. "\xCE" => '&#1470;',
  113. "\xCF" => '&#1471;',
  114. "\xD0" => '&#1472;',
  115. "\xD1" => '&#1473;',
  116. "\xD2" => '&#1474;',
  117. "\xD3" => '&#1475;',
  118. "\xD4" => '&#1520;',
  119. "\xD5" => '&#1521;',
  120. "\xD6" => '&#1522;',
  121. "\xD7" => '&#1523;',
  122. "\xD8" => '&#1524;',
  123. "\xD9" => '&#65533;',
  124. "\xDA" => '&#65533;',
  125. "\xDB" => '&#65533;',
  126. "\xDC" => '&#65533;',
  127. "\xDD" => '&#65533;',
  128. "\xDE" => '&#65533;',
  129. "\xDF" => '&#65533;',
  130. "\xE0" => '&#1488;',
  131. "\xE1" => '&#1489;',
  132. "\xE2" => '&#1490;',
  133. "\xE3" => '&#1491;',
  134. "\xE4" => '&#1492;',
  135. "\xE5" => '&#1493;',
  136. "\xE6" => '&#1494;',
  137. "\xE7" => '&#1495;',
  138. "\xE8" => '&#1496;',
  139. "\xE9" => '&#1497;',
  140. "\xEA" => '&#1498;',
  141. "\xEB" => '&#1499;',
  142. "\xEC" => '&#1500;',
  143. "\xED" => '&#1501;',
  144. "\xEE" => '&#1502;',
  145. "\xEF" => '&#1503;',
  146. "\xF0" => '&#1504;',
  147. "\xF1" => '&#1505;',
  148. "\xF2" => '&#1506;',
  149. "\xF3" => '&#1507;',
  150. "\xF4" => '&#1508;',
  151. "\xF5" => '&#1509;',
  152. "\xF6" => '&#1510;',
  153. "\xF7" => '&#1511;',
  154. "\xF8" => '&#1512;',
  155. "\xF9" => '&#1513;',
  156. "\xFA" => '&#1514;',
  157. "\xFB" => '&#65533;',
  158. "\xFC" => '&#65533;',
  159. "\xFD" => '&#8206;',
  160. "\xFE" => '&#8207;',
  161. "\xFF" => '&#65533;'
  162. );
  163. $string = str_replace(array_keys($cp1255), array_values($cp1255), $string);
  164. return $string;
  165. }