cp10081.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. /*
  3. * decode/cp10081.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 cp10081 (MacTurkish) decoding function that
  10. * is needed to read cp10081 encoded mails in non-cp10081 locale.
  11. *
  12. * Original data taken from:
  13. * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/TURKISH.TXT
  14. *
  15. * Name: cp10081_MacTurkish 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. */
  23. function charset_decode_cp10081 ($string) {
  24. global $default_charset;
  25. if (strtolower($default_charset) == 'x-mac-turkish')
  26. return $string;
  27. /* Only do the slow convert if there are 8-bit characters */
  28. /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
  29. if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
  30. return $string;
  31. $cp10081 = array(
  32. "\0x80" => '&#196;',
  33. "\0x81" => '&#197;',
  34. "\0x82" => '&#199;',
  35. "\0x83" => '&#201;',
  36. "\0x84" => '&#209;',
  37. "\0x85" => '&#214;',
  38. "\0x86" => '&#220;',
  39. "\0x87" => '&#225;',
  40. "\0x88" => '&#224;',
  41. "\0x89" => '&#226;',
  42. "\0x8A" => '&#228;',
  43. "\0x8B" => '&#227;',
  44. "\0x8C" => '&#229;',
  45. "\0x8D" => '&#231;',
  46. "\0x8E" => '&#233;',
  47. "\0x8F" => '&#232;',
  48. "\0x90" => '&#234;',
  49. "\0x91" => '&#235;',
  50. "\0x92" => '&#237;',
  51. "\0x93" => '&#236;',
  52. "\0x94" => '&#238;',
  53. "\0x95" => '&#239;',
  54. "\0x96" => '&#241;',
  55. "\0x97" => '&#243;',
  56. "\0x98" => '&#242;',
  57. "\0x99" => '&#244;',
  58. "\0x9A" => '&#246;',
  59. "\0x9B" => '&#245;',
  60. "\0x9C" => '&#250;',
  61. "\0x9D" => '&#249;',
  62. "\0x9E" => '&#251;',
  63. "\0x9F" => '&#252;',
  64. "\0xA0" => '&#8224;',
  65. "\0xA1" => '&#176;',
  66. "\0xA2" => '&#162;',
  67. "\0xA3" => '&#163;',
  68. "\0xA4" => '&#167;',
  69. "\0xA5" => '&#8226;',
  70. "\0xA6" => '&#182;',
  71. "\0xA7" => '&#223;',
  72. "\0xA8" => '&#174;',
  73. "\0xA9" => '&#169;',
  74. "\0xAA" => '&#8482;',
  75. "\0xAB" => '&#180;',
  76. "\0xAC" => '&#168;',
  77. "\0xAD" => '&#8800;',
  78. "\0xAE" => '&#198;',
  79. "\0xAF" => '&#216;',
  80. "\0xB0" => '&#8734;',
  81. "\0xB1" => '&#177;',
  82. "\0xB2" => '&#8804;',
  83. "\0xB3" => '&#8805;',
  84. "\0xB4" => '&#165;',
  85. "\0xB5" => '&#181;',
  86. "\0xB6" => '&#8706;',
  87. "\0xB7" => '&#8721;',
  88. "\0xB8" => '&#8719;',
  89. "\0xB9" => '&#960;',
  90. "\0xBA" => '&#8747;',
  91. "\0xBB" => '&#170;',
  92. "\0xBC" => '&#186;',
  93. "\0xBD" => '&#8486;',
  94. "\0xBE" => '&#230;',
  95. "\0xBF" => '&#248;',
  96. "\0xC0" => '&#191;',
  97. "\0xC1" => '&#161;',
  98. "\0xC2" => '&#172;',
  99. "\0xC3" => '&#8730;',
  100. "\0xC4" => '&#402;',
  101. "\0xC5" => '&#8776;',
  102. "\0xC6" => '&#8710;',
  103. "\0xC7" => '&#171;',
  104. "\0xC8" => '&#187;',
  105. "\0xC9" => '&#8230;',
  106. "\0xCA" => '&#160;',
  107. "\0xCB" => '&#192;',
  108. "\0xCC" => '&#195;',
  109. "\0xCD" => '&#213;',
  110. "\0xCE" => '&#338;',
  111. "\0xCF" => '&#339;',
  112. "\0xD0" => '&#8211;',
  113. "\0xD1" => '&#8212;',
  114. "\0xD2" => '&#8220;',
  115. "\0xD3" => '&#8221;',
  116. "\0xD4" => '&#8216;',
  117. "\0xD5" => '&#8217;',
  118. "\0xD6" => '&#247;',
  119. "\0xD7" => '&#9674;',
  120. "\0xD8" => '&#255;',
  121. "\0xD9" => '&#376;',
  122. "\0xDA" => '&#286;',
  123. "\0xDB" => '&#287;',
  124. "\0xDC" => '&#304;',
  125. "\0xDD" => '&#305;',
  126. "\0xDE" => '&#350;',
  127. "\0xDF" => '&#351;',
  128. "\0xE0" => '&#8225;',
  129. "\0xE1" => '&#183;',
  130. "\0xE2" => '&#8218;',
  131. "\0xE3" => '&#8222;',
  132. "\0xE4" => '&#8240;',
  133. "\0xE5" => '&#194;',
  134. "\0xE6" => '&#202;',
  135. "\0xE7" => '&#193;',
  136. "\0xE8" => '&#203;',
  137. "\0xE9" => '&#200;',
  138. "\0xEA" => '&#205;',
  139. "\0xEB" => '&#206;',
  140. "\0xEC" => '&#207;',
  141. "\0xED" => '&#204;',
  142. "\0xEE" => '&#211;',
  143. "\0xEF" => '&#212;',
  144. "\0xF0" => '&#65535;',
  145. "\0xF1" => '&#210;',
  146. "\0xF2" => '&#218;',
  147. "\0xF3" => '&#219;',
  148. "\0xF4" => '&#217;',
  149. "\0xF5" => '&#65535;',
  150. "\0xF6" => '&#710;',
  151. "\0xF7" => '&#732;',
  152. "\0xF8" => '&#175;',
  153. "\0xF9" => '&#728;',
  154. "\0xFA" => '&#729;',
  155. "\0xFB" => '&#730;',
  156. "\0xFC" => '&#184;',
  157. "\0xFD" => '&#733;',
  158. "\0xFE" => '&#731;',
  159. "\0xFF" => '&#711;'
  160. );
  161. $string = str_replace(array_keys($cp10081), array_values($cp10081), $string);
  162. return $string;
  163. }
  164. ?>