This file is indexed.

/usr/share/php/Patchwork/Utf8/BestFit.php is in php-patchwork-utf8 1.3.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php

/*
 * Copyright (C) 2016 Nicolas Grekas - p@tchwork.com
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the (at your option):
 * Apache License v2.0 (http://apache.org/licenses/LICENSE-2.0.txt), or
 * GNU General Public License v2.0 (http://gnu.org/licenses/gpl-2.0.txt).
 */

namespace Patchwork\Utf8;

/**
 * UTF-8 to Code Page conversion using best fit mappings
 * See http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/.
 */
class BestFit
{
    public static function fit($cp, $s, $placeholder = '?')
    {
        if (!$len = strlen($s)) {
            return 0 === $len ? '' : false;
        }

        static $map = array();
        static $ulen_mask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);

        $s .= '';
        $cp = (string) (int) $cp;
        $result = '9' === $cp[0] ? $s.$s : $s;

        if ('932' === $cp && 2 === func_num_args()) {
            $placeholder = "\x81\x45"; // Katakana Middle Dot in CP932
        }

        if (!isset($map[$cp])) {
            $i = static::getData('to.bestfit'.$cp);
            if (false === $i) {
                return false;
            }
            $map[$cp] = $i;
        }

        $i = $j = 0;
        $cp = $map[$cp];

        while ($i < $len) {
            if ($s[$i] < "\x80") {
                $uchr = $s[$i++];
            } else {
                $ulen = $ulen_mask[$s[$i] & "\xF0"];
                $uchr = substr($s, $i, $ulen);
                $i += $ulen;
            }

            if (isset($cp[$uchr])) {
                $uchr = $cp[$uchr];
            } else {
                $uchr = $placeholder;
            }

            isset($uchr[0]) and $result[$j++] = $uchr[0];
            isset($uchr[1]) and $result[$j++] = $uchr[1];
        }

        return substr($result, 0, $j);
    }

    protected static function getData($file)
    {
        $file = __DIR__.'/../../data/Patchwork/data/'.$file.'.ser';
        if (file_exists($file)) {
            return unserialize(file_get_contents($file));
        } else {
            return false;
        }
    }
}