Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

BestFit.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.06 KiB


01  <?php
02   
03  /*
04   * Copyright (C) 2016 Nicolas Grekas - p@tchwork.com
05   *
06   * This library is free software; you can redistribute it and/or modify it
07   * under the terms of the (at your option):
08   * Apache License v2.0 (http://apache.org/licenses/LICENSE-2.0.txt), or
09   * GNU General Public License v2.0 (http://gnu.org/licenses/gpl-2.0.txt).
10   */
11   
12  namespace Patchwork\Utf8;
13   
14  /**
15   * UTF-8 to Code Page conversion using best fit mappings
16   * See http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/.
17   */
18  class BestFit
19  {
20      public static function fit($cp, $s, $placeholder = '?')
21      {
22          if (!$len = strlen($s)) {
23              return 0 === $len ? '' : false;
24          }
25   
26          static $map = array();
27          static $ulen_mask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
28   
29          $s .= '';
30          $cp = (string) (int) $cp;
31          $result = '9' === $cp[0] ? $s.$s : $s;
32   
33          if ('932' === $cp && 2 === func_num_args()) {
34              $placeholder = "\x81\x45"; // Katakana Middle Dot in CP932
35          }
36   
37          if (!isset($map[$cp])) {
38              $i = static::getData('to.bestfit'.$cp);
39              if (false === $i) {
40                  return false;
41              }
42              $map[$cp] = $i;
43          }
44   
45          $i = $j = 0;
46          $cp = $map[$cp];
47   
48          while ($i < $len) {
49              if ($s[$i] < "\x80") {
50                  $uchr = $s[$i++];
51              } else {
52                  $ulen = $ulen_mask[$s[$i] & "\xF0"];
53                  $uchr = substr($s, $i, $ulen);
54                  $i += $ulen;
55              }
56   
57              if (isset($cp[$uchr])) {
58                  $uchr = $cp[$uchr];
59              } else {
60                  $uchr = $placeholder;
61              }
62   
63              isset($uchr[0]) and $result[$j++] = $uchr[0];
64              isset($uchr[1]) and $result[$j++] = $uchr[1];
65          }
66   
67          return substr($result, 0, $j);
68      }
69   
70      protected static function getData($file)
71      {
72          $file = __DIR__.'/data/'.$file.'.ser';
73          if (file_exists($file)) {
74              return unserialize(file_get_contents($file));
75          } else {
76              return false;
77          }
78      }
79  }
80