cp10029.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. /**
  3. * decode/cp10029.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 cp10029 (MacLatin2) decoding function that
  10. * is needed to read cp10029 encoded mails in non-cp10029 locale.
  11. *
  12. * Original data taken from:
  13. * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/LATIN2.TXT
  14. *
  15. * Name: cp10029_MacLatin2 to Unicode table
  16. * Unicode version: 2.0
  17. * Table version: 2.00
  18. * Table format: Format A
  19. * Date: 04/24/96
  20. * Authors: Lori Brownell <loribr@microsoft.com>
  21. * K.D. Chang <a-kchang@microsoft.com>
  22. * @package squirrelmail
  23. * @subpackage decode
  24. */
  25. /**
  26. * Decode cp10029 (MacLatin2) string
  27. * @param string $string Encoded string
  28. * @return string $string Decoded string
  29. */
  30. function charset_decode_cp10029 ($string) {
  31. global $default_charset;
  32. if (strtolower($default_charset) == 'x-mac-centraleurroman')
  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. $cp10029 = array(
  39. "\0x80" => '&#196;',
  40. "\0x81" => '&#256;',
  41. "\0x82" => '&#257;',
  42. "\0x83" => '&#201;',
  43. "\0x84" => '&#260;',
  44. "\0x85" => '&#214;',
  45. "\0x86" => '&#220;',
  46. "\0x87" => '&#225;',
  47. "\0x88" => '&#261;',
  48. "\0x89" => '&#268;',
  49. "\0x8A" => '&#228;',
  50. "\0x8B" => '&#269;',
  51. "\0x8C" => '&#262;',
  52. "\0x8D" => '&#263;',
  53. "\0x8E" => '&#233;',
  54. "\0x8F" => '&#377;',
  55. "\0x90" => '&#378;',
  56. "\0x91" => '&#270;',
  57. "\0x92" => '&#237;',
  58. "\0x93" => '&#271;',
  59. "\0x94" => '&#274;',
  60. "\0x95" => '&#275;',
  61. "\0x96" => '&#278;',
  62. "\0x97" => '&#243;',
  63. "\0x98" => '&#279;',
  64. "\0x99" => '&#244;',
  65. "\0x9A" => '&#246;',
  66. "\0x9B" => '&#245;',
  67. "\0x9C" => '&#250;',
  68. "\0x9D" => '&#282;',
  69. "\0x9E" => '&#283;',
  70. "\0x9F" => '&#252;',
  71. "\0xA0" => '&#8224;',
  72. "\0xA1" => '&#176;',
  73. "\0xA2" => '&#280;',
  74. "\0xA3" => '&#163;',
  75. "\0xA4" => '&#167;',
  76. "\0xA5" => '&#8226;',
  77. "\0xA6" => '&#182;',
  78. "\0xA7" => '&#223;',
  79. "\0xA8" => '&#174;',
  80. "\0xA9" => '&#169;',
  81. "\0xAA" => '&#8482;',
  82. "\0xAB" => '&#281;',
  83. "\0xAC" => '&#168;',
  84. "\0xAD" => '&#8800;',
  85. "\0xAE" => '&#291;',
  86. "\0xAF" => '&#302;',
  87. "\0xB0" => '&#303;',
  88. "\0xB1" => '&#298;',
  89. "\0xB2" => '&#8804;',
  90. "\0xB3" => '&#8805;',
  91. "\0xB4" => '&#299;',
  92. "\0xB5" => '&#310;',
  93. "\0xB6" => '&#8706;',
  94. "\0xB7" => '&#8721;',
  95. "\0xB8" => '&#322;',
  96. "\0xB9" => '&#315;',
  97. "\0xBA" => '&#316;',
  98. "\0xBB" => '&#317;',
  99. "\0xBC" => '&#318;',
  100. "\0xBD" => '&#313;',
  101. "\0xBE" => '&#314;',
  102. "\0xBF" => '&#325;',
  103. "\0xC0" => '&#326;',
  104. "\0xC1" => '&#323;',
  105. "\0xC2" => '&#172;',
  106. "\0xC3" => '&#8730;',
  107. "\0xC4" => '&#324;',
  108. "\0xC5" => '&#327;',
  109. "\0xC6" => '&#8710;',
  110. "\0xC7" => '&#171;',
  111. "\0xC8" => '&#187;',
  112. "\0xC9" => '&#8230;',
  113. "\0xCA" => '&#160;',
  114. "\0xCB" => '&#328;',
  115. "\0xCC" => '&#336;',
  116. "\0xCD" => '&#213;',
  117. "\0xCE" => '&#337;',
  118. "\0xCF" => '&#332;',
  119. "\0xD0" => '&#8211;',
  120. "\0xD1" => '&#8212;',
  121. "\0xD2" => '&#8220;',
  122. "\0xD3" => '&#8221;',
  123. "\0xD4" => '&#8216;',
  124. "\0xD5" => '&#8217;',
  125. "\0xD6" => '&#247;',
  126. "\0xD7" => '&#9674;',
  127. "\0xD8" => '&#333;',
  128. "\0xD9" => '&#340;',
  129. "\0xDA" => '&#341;',
  130. "\0xDB" => '&#344;',
  131. "\0xDC" => '&#8249;',
  132. "\0xDD" => '&#8250;',
  133. "\0xDE" => '&#345;',
  134. "\0xDF" => '&#342;',
  135. "\0xE0" => '&#343;',
  136. "\0xE1" => '&#352;',
  137. "\0xE2" => '&#8218;',
  138. "\0xE3" => '&#8222;',
  139. "\0xE4" => '&#353;',
  140. "\0xE5" => '&#346;',
  141. "\0xE6" => '&#347;',
  142. "\0xE7" => '&#193;',
  143. "\0xE8" => '&#356;',
  144. "\0xE9" => '&#357;',
  145. "\0xEA" => '&#205;',
  146. "\0xEB" => '&#381;',
  147. "\0xEC" => '&#382;',
  148. "\0xED" => '&#362;',
  149. "\0xEE" => '&#211;',
  150. "\0xEF" => '&#212;',
  151. "\0xF0" => '&#363;',
  152. "\0xF1" => '&#366;',
  153. "\0xF2" => '&#218;',
  154. "\0xF3" => '&#367;',
  155. "\0xF4" => '&#368;',
  156. "\0xF5" => '&#369;',
  157. "\0xF6" => '&#370;',
  158. "\0xF7" => '&#371;',
  159. "\0xF8" => '&#221;',
  160. "\0xF9" => '&#253;',
  161. "\0xFA" => '&#311;',
  162. "\0xFB" => '&#379;',
  163. "\0xFC" => '&#321;',
  164. "\0xFD" => '&#380;',
  165. "\0xFE" => '&#290;',
  166. "\0xFF" => '&#711;'
  167. );
  168. $string = str_replace(array_keys($cp10029), array_values($cp10029), $string);
  169. return $string;
  170. }
  171. ?>