/usr/share/php/Patchwork/TurkishUtf8.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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | <?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;
/**
* Turkish locale specialized version of Patchwork\Utf8.
*/
class TurkishUtf8 extends Utf8
{
public static function strtocasefold($s, $full = true)
{
if (false !== strpos($s, 'İ')) {
$s = str_replace('İ', 'i', $s);
}
return parent::strtocasefold($s, $full);
}
public static function stripos($s, $needle, $offset = 0)
{
if (false !== strpos($needle, 'I')) {
$needle = str_replace('I', 'ı', $needle);
}
if (false !== strpos($needle, 'İ')) {
$needle = str_replace('İ', 'i', $needle);
}
if (false !== strpos($s, 'I')) {
$s = str_replace('I', 'ı', $s);
}
if (false !== strpos($s, 'İ')) {
$s = str_replace('İ', 'i', $s);
}
return parent::stripos($s, $needle, $offset);
}
public static function strripos($s, $needle, $offset = 0)
{
if (false !== strpos($needle, 'I')) {
$needle = str_replace('I', 'ı', $needle);
}
if (false !== strpos($needle, 'İ')) {
$needle = str_replace('İ', 'i', $needle);
}
if (false !== strpos($s, 'I')) {
$s = str_replace('I', 'ı', $s);
}
if (false !== strpos($s, 'İ')) {
$s = str_replace('İ', 'i', $s);
}
return parent::strripos($s, $needle, $offset);
}
public static function stristr($s, $needle, $before_needle = false)
{
$needle = self::stripos($s, $needle);
if (false === $needle) {
return false;
}
if ($before_needle) {
return self::substr($s, 0, $needle);
}
return self::substr($s, $needle);
}
public static function strrichr($s, $needle, $before_needle = false)
{
$needle = self::strripos($s, $needle);
if (false === $needle) {
return false;
}
if ($before_needle) {
return self::substr($s, 0, $needle);
}
return self::substr($s, $needle);
}
public static function strtolower($s)
{
if (false !== strpos($s, 'İ')) {
$s = str_replace('İ', 'i', $s);
}
if (false !== strpos($s, 'I')) {
$s = str_replace('I', 'ı', $s);
}
return parent::strtolower($s);
}
public static function strtoupper($s)
{
if (false !== strpos($s, 'i')) {
$s = str_replace('i', 'İ', $s);
}
return parent::strtoupper($s);
}
public static function str_ireplace($search, $replace, $subject, &$count = null)
{
$search = (array) $search;
foreach ($search as $i => $s) {
if ('' === $s .= '') {
$s = '/^(?<=.)$/';
} else {
$s = preg_quote($s, '/');
$s = strtr($s, array(
'i' => '(?-i:[iİ])',
'İ' => '(?-i:[iİ])',
'ı' => '(?-i:[ıI])',
'I' => '(?-i:[ıI])',
));
$s = "/{$s}/ui";
}
$search[$i] = $s;
}
$subject = preg_replace($search, $replace, $subject, -1, $replace);
$count = $replace;
return $subject;
}
public static function ucfirst($s)
{
if ('i' === substr($s, 0, 1)) {
return 'İ'.substr($s, 1);
} else {
return parent::ucfirst($s);
}
}
public static function ucwords($s)
{
if (false !== strpos($s, 'i')) {
$s = preg_replace('/\bi/u', 'İ', $s);
}
return parent::ucwords($s);
}
}
|