iso_ir_111.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /**
  3. * decode/iso-ir-111.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 iso-ir-111 decoding function that is needed to read
  9. * iso-ir-111 encoded mails in non-iso-ir-111 locale.
  10. *
  11. * Original data taken from:
  12. * http://crl.nmsu.edu/~mleisher/csets/ISOIR111.TXT
  13. *
  14. * Original ID: Id: ISOIR111.TXT,v 1.2 1999/08/23 18:34:15 mleisher Exp
  15. * Name: ISO IR 111/ECMA Cyrillic to Unicode 2.1 mapping table.
  16. * Typed in by hand from
  17. * http://www.fingertipsoft.com/ref/cyrillic/charsets.html
  18. * Author: Mark Leisher <mleisher@crl.nmsu.edu>
  19. * Date: 05 March 1998
  20. *
  21. * Original copyright:
  22. * Copyright 1999 Computing Research Labs, New Mexico State University
  23. *
  24. * Permission is hereby granted, free of charge, to any person obtaining a
  25. * copy of this software and associated documentation files (the ""Software""),
  26. * to deal in the Software without restriction, including without limitation
  27. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  28. * and/or sell copies of the Software, and to permit persons to whom the
  29. * Software is furnished to do so, subject to the following conditions:
  30. *
  31. * The above copyright notice and this permission notice shall be included in
  32. * all copies or substantial portions of the Software.
  33. *
  34. * THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  35. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  36. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  37. * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
  38. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
  39. * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
  40. * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  41. *
  42. * @version $Id$
  43. * @package squirrelmail
  44. * @subpackage decode
  45. */
  46. /**
  47. * Decode iso-ir-111 encoded strings
  48. * @param string $string Encoded string
  49. * @return string Decoded string
  50. */
  51. function charset_decode_iso_ir_111 ($string) {
  52. global $default_charset;
  53. if (strtolower($default_charset) == 'iso-ir-111')
  54. return $string;
  55. /* Only do the slow convert if there are 8-bit characters */
  56. /* there is no 0x80-0x9F letters in ISO-IR-111 */
  57. if ( ! ereg("[\241-\377]", $string) )
  58. return $string;
  59. $iso_ir_111 = array(
  60. "\xA0" => '&#160;',
  61. "\xA1" => '&#1106;',
  62. "\xA2" => '&#1107;',
  63. "\xA3" => '&#1105;',
  64. "\xA4" => '&#1108;',
  65. "\xA5" => '&#1109;',
  66. "\xA6" => '&#1110;',
  67. "\xA7" => '&#1111;',
  68. "\xA8" => '&#1112;',
  69. "\xA9" => '&#1113;',
  70. "\xAA" => '&#1114;',
  71. "\xAB" => '&#1115;',
  72. "\xAC" => '&#1116;',
  73. "\xAD" => '&#173;',
  74. "\xAE" => '&#1118;',
  75. "\xAF" => '&#1119;',
  76. "\xB0" => '&#8470;',
  77. "\xB1" => '&#1026;',
  78. "\xB2" => '&#1027;',
  79. "\xB3" => '&#1025;',
  80. "\xB4" => '&#1028;',
  81. "\xB5" => '&#1029;',
  82. "\xB6" => '&#1030;',
  83. "\xB7" => '&#1031;',
  84. "\xB8" => '&#1032;',
  85. "\xB9" => '&#1033;',
  86. "\xBA" => '&#1034;',
  87. "\xBB" => '&#1035;',
  88. "\xBC" => '&#1036;',
  89. "\xBD" => '&#164;',
  90. "\xBE" => '&#1038;',
  91. "\xBF" => '&#1039;',
  92. "\xC0" => '&#1102;',
  93. "\xC1" => '&#1072;',
  94. "\xC2" => '&#1073;',
  95. "\xC3" => '&#1094;',
  96. "\xC4" => '&#1076;',
  97. "\xC5" => '&#1077;',
  98. "\xC6" => '&#1092;',
  99. "\xC7" => '&#1075;',
  100. "\xC8" => '&#1093;',
  101. "\xC9" => '&#1080;',
  102. "\xCA" => '&#1081;',
  103. "\xCB" => '&#1082;',
  104. "\xCC" => '&#1083;',
  105. "\xCD" => '&#1084;',
  106. "\xCE" => '&#1085;',
  107. "\xCF" => '&#1086;',
  108. "\xD0" => '&#1087;',
  109. "\xD1" => '&#1103;',
  110. "\xD2" => '&#1088;',
  111. "\xD3" => '&#1089;',
  112. "\xD4" => '&#1090;',
  113. "\xD5" => '&#1091;',
  114. "\xD6" => '&#1078;',
  115. "\xD7" => '&#1074;',
  116. "\xD8" => '&#1100;',
  117. "\xD9" => '&#1099;',
  118. "\xDA" => '&#1079;',
  119. "\xDB" => '&#1096;',
  120. "\xDC" => '&#1101;',
  121. "\xDD" => '&#1097;',
  122. "\xDE" => '&#1095;',
  123. "\xDF" => '&#1098;',
  124. "\xE0" => '&#1070;',
  125. "\xE1" => '&#1040;',
  126. "\xE2" => '&#1041;',
  127. "\xE3" => '&#1062;',
  128. "\xE4" => '&#1044;',
  129. "\xE5" => '&#1045;',
  130. "\xE6" => '&#1060;',
  131. "\xE7" => '&#1043;',
  132. "\xE8" => '&#1061;',
  133. "\xE9" => '&#1048;',
  134. "\xEA" => '&#1049;',
  135. "\xEB" => '&#1050;',
  136. "\xEC" => '&#1051;',
  137. "\xED" => '&#1052;',
  138. "\xEE" => '&#1053;',
  139. "\xEF" => '&#1054;',
  140. "\xF0" => '&#1055;',
  141. "\xF1" => '&#1071;',
  142. "\xF2" => '&#1056;',
  143. "\xF3" => '&#1057;',
  144. "\xF4" => '&#1058;',
  145. "\xF5" => '&#1059;',
  146. "\xF6" => '&#1046;',
  147. "\xF7" => '&#1042;',
  148. "\xF8" => '&#1068;',
  149. "\xF9" => '&#1067;',
  150. "\xFA" => '&#1047;',
  151. "\xFB" => '&#1064;',
  152. "\xFC" => '&#1069;',
  153. "\xFD" => '&#1065;',
  154. "\xFE" => '&#1063;',
  155. "\xFF" => '&#1066;'
  156. );
  157. $string = str_replace(array_keys($iso_ir_111), array_values($iso_ir_111), $string);
  158. return $string;
  159. }
  160. ?>