Source for file cp866.php

Documentation is available at cp866.php

  1. <?php
  2.  
  3. /**
  4.  * decode/cp866.php
  5.  *
  6.  * This file contains cp866 decoding function that is needed to read
  7.  * cp866 encoded mails in non-cp866 locale.
  8.  *
  9.  * Original data taken from:
  10.  *  ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/
  11.  
  12.     Name:     cp866_DOSCyrillicRussian to Unicode table
  13.     Unicode version: 2.0
  14.     Table version: 2.00
  15.     Table format:  Format A
  16.     Date:          04/24/96
  17.     Authors:       Lori Brownell <[email protected]>
  18.                    K.D. Chang    <[email protected]>
  19.     The entries are in cp866_DOSCyrillicRussian order
  20.  *
  21.  * @copyright 2003-2020 The SquirrelMail Project Team
  22.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  23.  * @version $Id: cp866.php 14840 2020-01-07 07:42:38Z pdontthink $
  24.  * @package squirrelmail
  25.  * @subpackage decode
  26. */
  27.  
  28. /**
  29.  * Decode a cp866-encoded string
  30.  * @param string $string Encoded string
  31.  * @return string $string Decoded string
  32.  */
  33. function charset_decode_cp866 ($string{
  34.     // don't do decoding when there are no 8bit symbols
  35.     if (sq_is8bit($string,'ibm866'))
  36.         return $string;
  37.  
  38.     $cp866 array(
  39.         "\x80" => '&#1040;',
  40.         "\x81" => '&#1041;',
  41.         "\x82" => '&#1042;',
  42.         "\x83" => '&#1043;',
  43.         "\x84" => '&#1044;',
  44.         "\x85" => '&#1045;',
  45.         "\x86" => '&#1046;',
  46.         "\x87" => '&#1047;',
  47.         "\x88" => '&#1048;',
  48.         "\x89" => '&#1049;',
  49.         "\x8a" => '&#1050;',
  50.         "\x8b" => '&#1051;',
  51.         "\x8c" => '&#1052;',
  52.         "\x8d" => '&#1053;',
  53.         "\x8e" => '&#1054;',
  54.         "\x8f" => '&#1055;',
  55.         "\x90" => '&#1056;',
  56.         "\x91" => '&#1057;',
  57.         "\x92" => '&#1058;',
  58.         "\x93" => '&#1059;',
  59.         "\x94" => '&#1060;',
  60.         "\x95" => '&#1061;',
  61.         "\x96" => '&#1062;',
  62.         "\x97" => '&#1063;',
  63.         "\x98" => '&#1064;',
  64.         "\x99" => '&#1065;',
  65.         "\x9a" => '&#1066;',
  66.         "\x9b" => '&#1067;',
  67.         "\x9c" => '&#1068;',
  68.         "\x9d" => '&#1069;',
  69.         "\x9e" => '&#1070;',
  70.         "\x9f" => '&#1071;',
  71.         "\xa0" => '&#1072;',
  72.         "\xa1" => '&#1073;',
  73.         "\xa2" => '&#1074;',
  74.         "\xa3" => '&#1075;',
  75.         "\xa4" => '&#1076;',
  76.         "\xa5" => '&#1077;',
  77.         "\xa6" => '&#1078;',
  78.         "\xa7" => '&#1079;',
  79.         "\xa8" => '&#1080;',
  80.         "\xa9" => '&#1081;',
  81.         "\xaa" => '&#1082;',
  82.         "\xab" => '&#1083;',
  83.         "\xac" => '&#1084;',
  84.         "\xad" => '&#1085;',
  85.         "\xae" => '&#1086;',
  86.         "\xaf" => '&#1087;',
  87.         "\xb0" => '&#9617;',
  88.         "\xb1" => '&#9618;',
  89.         "\xb2" => '&#9619;',
  90.         "\xb3" => '&#9474;',
  91.         "\xb4" => '&#9508;',
  92.         "\xb5" => '&#9569;',
  93.         "\xb6" => '&#9570;',
  94.         "\xb7" => '&#9558;',
  95.         "\xb8" => '&#9557;',
  96.         "\xb9" => '&#9571;',
  97.         "\xba" => '&#9553;',
  98.         "\xbb" => '&#9559;',
  99.         "\xbc" => '&#9565;',
  100.         "\xbd" => '&#9564;',
  101.         "\xbe" => '&#9563;',
  102.         "\xbf" => '&#9488;',
  103.         "\xc0" => '&#9492;',
  104.         "\xc1" => '&#9524;',
  105.         "\xc2" => '&#9516;',
  106.         "\xc3" => '&#9500;',
  107.         "\xc4" => '&#9472;',
  108.         "\xc5" => '&#9532;',
  109.         "\xc6" => '&#9566;',
  110.         "\xc7" => '&#9567;',
  111.         "\xc8" => '&#9562;',
  112.         "\xc9" => '&#9556;',
  113.         "\xca" => '&#9577;',
  114.         "\xcb" => '&#9574;',
  115.         "\xcc" => '&#9568;',
  116.         "\xcd" => '&#9552;',
  117.         "\xce" => '&#9580;',
  118.         "\xcf" => '&#9575;',
  119.         "\xd0" => '&#9576;',
  120.         "\xd1" => '&#9572;',
  121.         "\xd2" => '&#9573;',
  122.         "\xd3" => '&#9561;',
  123.         "\xd4" => '&#9560;',
  124.         "\xd5" => '&#9554;',
  125.         "\xd6" => '&#9555;',
  126.         "\xd7" => '&#9579;',
  127.         "\xd8" => '&#9578;',
  128.         "\xd9" => '&#9496;',
  129.         "\xda" => '&#9484;',
  130.         "\xdb" => '&#9608;',
  131.         "\xdc" => '&#9604;',
  132.         "\xdd" => '&#9612;',
  133.         "\xde" => '&#9616;',
  134.         "\xdf" => '&#9600;',
  135.         "\xe0" => '&#1088;',
  136.         "\xe1" => '&#1089;',
  137.         "\xe2" => '&#1090;',
  138.         "\xe3" => '&#1091;',
  139.         "\xe4" => '&#1092;',
  140.         "\xe5" => '&#1093;',
  141.         "\xe6" => '&#1094;',
  142.         "\xe7" => '&#1095;',
  143.         "\xe8" => '&#1096;',
  144.         "\xe9" => '&#1097;',
  145.         "\xea" => '&#1098;',
  146.         "\xeb" => '&#1099;',
  147.         "\xec" => '&#1100;',
  148.         "\xed" => '&#1101;',
  149.         "\xee" => '&#1102;',
  150.         "\xef" => '&#1103;',
  151.         "\xf0" => '&#1025;',
  152.         "\xf1" => '&#1105;',
  153.         "\xf2" => '&#1028;',
  154.         "\xf3" => '&#1108;',
  155.         "\xf4" => '&#1031;',
  156.         "\xf5" => '&#1111;',
  157.         "\xf6" => '&#1038;',
  158.         "\xf7" => '&#1118;',
  159.         "\xf8" => '&#176;',
  160.         "\xf9" => '&#8729;',
  161.         "\xfa" => '&#183;',
  162.         "\xfb" => '&#8730;',
  163.         "\xfc" => '&#8470;',
  164.         "\xfd" => '&#164;',
  165.         "\xfe" => '&#9632;',
  166.         "\xff" => '&#160;'
  167.     );
  168.  
  169.     $string str_replace(array_keys($cp866)array_values($cp866)$string);
  170.  
  171.     return $string;
  172. }

Documentation generated on Mon, 13 Jan 2020 04:24:24 +0100 by phpDocumentor 1.4.3