iso-ir-111.php 4.4 KB

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