iso_ir_111.php 5.1 KB

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