Source for file koi8_u.php

Documentation is available at koi8_u.php

  1. <?php
  2.  
  3. /**
  4.  * decode/koi8-u.php
  5.  *
  6.  * This file contains koi8-u decoding function that is needed to read
  7.  * koi8-u encoded mails in non-koi8-u locale.
  8.  *
  9.  * Original data taken from rfc2319
  10.  *
  11.  * Original copyright:
  12.  *
  13.  * Copyright (C) The Internet Society (1998).  All Rights Reserved.
  14.  *
  15.  * This document and translations of it may be copied and furnished to
  16.  * others, and derivative works that comment on or otherwise explain it
  17.  * or assist in its implementation may be prepared, copied, published
  18.  * and distributed, in whole or in part, without restriction of any
  19.  * kind, provided that the above copyright notice and this paragraph are
  20.  * included on all such copies and derivative works.  However, this
  21.  * document itself may not be modified in any way, such as by removing
  22.  * the copyright notice or references to the Internet Society or other
  23.  * Internet organizations, except as needed for the purpose of
  24.  * developing Internet standards in which case the procedures for
  25.  * copyrights defined in the Internet Standards process must be
  26.  * followed, or as required to translate it into languages other than
  27.  * English.
  28.  *
  29.  * The limited permissions granted above are perpetual and will not be
  30.  * revoked by the Internet Society or its successors or assigns.
  31.  *
  32.  * This document and the information contained herein is provided on an
  33.  * "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
  34.  * TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
  35.  * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
  36.  * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
  37.  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  38.  *
  39.  * @copyright 2003-2020 The SquirrelMail Project Team
  40.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  41.  * @version $Id: koi8_u.php 14840 2020-01-07 07:42:38Z pdontthink $
  42.  * @package squirrelmail
  43.  * @subpackage decode
  44.  */
  45.  
  46. /**
  47.  * Decode koi8-u encoded strings
  48.  * @param string $string Encoded string
  49.  * @return string Decoded string
  50.  */
  51. function charset_decode_koi8_u ($string{
  52.     // don't do decoding when there are no 8bit symbols
  53.     if (sq_is8bit($string,'koi8-u'))
  54.         return $string;
  55.  
  56.     $koi8u array(
  57.         "\x80" => '&#9472;',
  58.         "\x81" => '&#9474;',
  59.         "\x82" => '&#9484;',
  60.         "\x83" => '&#9488;',
  61.         "\x84" => '&#9492;',
  62.         "\x85" => '&#9496;',
  63.         "\x86" => '&#9500;',
  64.         "\x87" => '&#9508;',
  65.         "\x88" => '&#9516;',
  66.         "\x89" => '&#9524;',
  67.         "\x8A" => '&#9532;',
  68.         "\x8B" => '&#9600;',
  69.         "\x8C" => '&#9604;',
  70.         "\x8D" => '&#9608;',
  71.         "\x8E" => '&#9612;',
  72.         "\x8F" => '&#9616;',
  73.         "\x90" => '&#9617;',
  74.         "\x91" => '&#9618;',
  75.         "\x92" => '&#9619;',
  76.         "\x93" => '&#8992;',
  77.         "\x94" => '&#9632;',
  78.         "\x95" => '&#8729;',
  79.         "\x96" => '&#8730;',
  80.         "\x97" => '&#8776;',
  81.         "\x98" => '&#8804;',
  82.         "\x99" => '&#8805;',
  83.         "\x9A" => '&#160;',
  84.         "\x9B" => '&#8993;',
  85.         "\x9C" => '&#176;',
  86.         "\x9D" => '&#178;',
  87.         "\x9E" => '&#183;',
  88.         "\x9F" => '&#247;',
  89.         "\xA0" => '&#9552;',
  90.         "\xA1" => '&#9553;',
  91.         "\xA2" => '&#9554;',
  92.         "\xA3" => '&#1105;',
  93.         "\xA4" => '&#1108;',
  94.         "\xA5" => '&#9556;',
  95.         "\xA6" => '&#1110;',
  96.         "\xA7" => '&#1111;',
  97.         "\xA8" => '&#9559;',
  98.         "\xA9" => '&#9560;',
  99.         "\xAA" => '&#9561;',
  100.         "\xAB" => '&#9562;',
  101.         "\xAC" => '&#9563;',
  102.         "\xAD" => '&#1169;',
  103.         "\xAE" => '&#9565;',
  104.         "\xAF" => '&#9566;',
  105.         "\xB0" => '&#9567;',
  106.         "\xB1" => '&#9568;',
  107.         "\xB2" => '&#9569;',
  108.         "\xB3" => '&#1025;',
  109.         "\xB4" => '&#1027;',
  110.         "\xB5" => '&#9571;',
  111.         "\xB6" => '&#1030;',
  112.         "\xB7" => '&#1031;',
  113.         "\xB8" => '&#9574;',
  114.         "\xB9" => '&#9575;',
  115.         "\xBA" => '&#9576;',
  116.         "\xBB" => '&#9577;',
  117.         "\xBC" => '&#9578;',
  118.         "\xBD" => '&#1168;',
  119.         "\xBE" => '&#9580;',
  120.         "\xBF" => '&#169;',
  121.         "\xC0" => '&#1102;',
  122.         "\xC1" => '&#1072;',
  123.         "\xC2" => '&#1073;',
  124.         "\xC3" => '&#1094;',
  125.         "\xC4" => '&#1076;',
  126.         "\xC5" => '&#1077;',
  127.         "\xC6" => '&#1092;',
  128.         "\xC7" => '&#1075;',
  129.         "\xC8" => '&#1093;',
  130.         "\xC9" => '&#1080;',
  131.         "\xCA" => '&#1081;',
  132.         "\xCB" => '&#1082;',
  133.         "\xCC" => '&#1083;',
  134.         "\xCD" => '&#1084;',
  135.         "\xCE" => '&#1085;',
  136.         "\xCF" => '&#1086;',
  137.         "\xD0" => '&#1087;',
  138.         "\xD1" => '&#1103;',
  139.         "\xD2" => '&#1088;',
  140.         "\xD3" => '&#1089;',
  141.         "\xD4" => '&#1090;',
  142.         "\xD5" => '&#1091;',
  143.         "\xD6" => '&#1078;',
  144.         "\xD7" => '&#1074;',
  145.         "\xD8" => '&#1100;',
  146.         "\xD9" => '&#1099;',
  147.         "\xDA" => '&#1079;',
  148.         "\xDB" => '&#1096;',
  149.         "\xDC" => '&#1101;',
  150.         "\xDD" => '&#1097;',
  151.         "\xDE" => '&#1095;',
  152.         "\xDF" => '&#1098;',
  153.         "\xE0" => '&#1070;',
  154.         "\xE1" => '&#1040;',
  155.         "\xE2" => '&#1041;',
  156.         "\xE3" => '&#1062;',
  157.         "\xE4" => '&#1044;',
  158.         "\xE5" => '&#1045;',
  159.         "\xE6" => '&#1060;',
  160.         "\xE7" => '&#1043;',
  161.         "\xE8" => '&#1061;',
  162.         "\xE9" => '&#1048;',
  163.         "\xEA" => '&#1049;',
  164.         "\xEB" => '&#1050;',
  165.         "\xEC" => '&#1051;',
  166.         "\xED" => '&#1052;',
  167.         "\xEE" => '&#1053;',
  168.         "\xEF" => '&#1054;',
  169.         "\xF0" => '&#1055;',
  170.         "\xF1" => '&#1071;',
  171.         "\xF2" => '&#1056;',
  172.         "\xF3" => '&#1057;',
  173.         "\xF4" => '&#1058;',
  174.         "\xF5" => '&#1059;',
  175.         "\xF6" => '&#1046;',
  176.         "\xF7" => '&#1042;',
  177.         "\xF8" => '&#1068;',
  178.         "\xF9" => '&#1067;',
  179.         "\xFA" => '&#1047;',
  180.         "\xFB" => '&#1064;',
  181.         "\xFC" => '&#1069;',
  182.         "\xFD" => '&#1065;',
  183.         "\xFE" => '&#1063;',
  184.         "\xFF" => '&#1066;'
  185.     );
  186.  
  187.     $string str_replace(array_keys($koi8u)array_values($koi8u)$string);
  188.  
  189.     return $string;
  190. }

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