CINXE.COM
PhpString.php - OpenGrok cross reference for /dokuwiki/inc/Utf8/PhpString.php
<!DOCTYPE html> <html lang="en" class="xref"> <head> <meta charset="UTF-8"> <meta name="robots" content="noindex,nofollow" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="generator" content="{OpenGrok 1.7.31 (6333fd74002ce5c6b4229b0c7460bd5acab9adec)" /> <meta name="theme-color" content="#ffffff"> <link rel="icon" href="/default/img/favicon.svg"> <link rel="mask-icon" href="/default/img/mask-icon.svg" color="#000000"> <link rel="apple-touch-icon" href="/default/img/apple-touch-icon.png"> <link rel="manifest" href="/manifest.json"> <link rel="preload" href="/default/font/SunSansRegular.woff2" as="font" type="font/woff2" crossorigin> <link rel="stylesheet" type="text/css" media="all" title="Default" href="/default/style-1.0.4.min.css" /> <link rel="alternate stylesheet" type="text/css" media="all" title="Paper White" href="/default/print-1.0.2.min.css" /> <link rel="stylesheet" type="text/css" href="/default/mandoc-1.0.0.min.css" media="all" /> <link rel="stylesheet" type="text/css" href="/default/print-1.0.2.min.css" media="print" /> <link rel="stylesheet" type="text/css" href="/default/jquery-ui-1.12.1-custom.min.css" /> <link rel="stylesheet" type="text/css" href="/default/jquery-ui-1.12.1-custom.structure.min.css" /> <link rel="stylesheet" type="text/css" href="/default/jquery-ui-1.12.1-custom.theme.min.css" /> <link rel="stylesheet" type="text/css" href="/default/jquery.tooltip.min.css" /> <link rel="stylesheet" type="text/css" href="/default/jquery.tablesorter.min.css" /> <link rel="stylesheet" type="text/css" href="/default/searchable-option-list-2.0.3.min.css" /> <link rel="search" href="/opensearch" type="application/opensearchdescription+xml" title="OpenGrok Search for current project(s)" /> <script type="text/javascript">/* <![CDATA[ */ window.contextPath = ''; document.xrefPath = '/xref'; document.pageReady = []; document.domReady = []; /* ]]> */ </script> <title>PhpString.php - OpenGrok cross reference for /dokuwiki/inc/Utf8/PhpString.php</title></head><body> <script type="text/javascript">/* <![CDATA[ */ document.rev = function() { return getParameter("r"); }; document.annotate = false; document.domReady.push(function() { domReadyMast(); }); document.pageReady.push(function() { pageReadyMast(); }); /* ]]> */</script> <div id="page"> <header id="whole_header"> <div id="Masthead"> <a href="/xref/">xref</a>: /<a href="/xref/dokuwiki/">dokuwiki</a>/<a href="/xref/dokuwiki/inc/">inc</a>/<a href="/xref/dokuwiki/inc/Utf8/">Utf8</a>/<a href="/xref/dokuwiki/inc/Utf8/PhpString.php">PhpString.php</a><span id="dtag"> </span> </div> <form action="/search"> <div id="bar"> <ul> <li><a href="/"><span id="home"></span>Home</a></li><li><span id="history"></span><span class="c">History</span></li><li><span class="c"><span class="annotate"></span>Annotate</span></li><li><a href="#" onclick="lntoggle();return false;" title="Show or hide line numbers (might be slower if file has more than 10 000 lines)."> <span id="line"></span>Line#</a></li> <li><a href="#" class="scopes-toggle" title="Show or hide scopes window."> <span id="scopes"></span>Scopes#</a></li> <li><a href="#" id="navigate" title="Show or hide symbol list."> <span id="defbox"></span>Navigate#</a></li><li><a href="/raw/dokuwiki/inc/Utf8/PhpString.php"><span id="raw"></span>Raw</a></li> <li><a href="/download/dokuwiki/inc/Utf8/PhpString.php"><span id="download"></span>Download</a></li> <li><input type="text" id="search" name="full" class="q" aria-label="Search"/></li> <li><input type="submit" value="Search" class="submit" /></li><li><label><input id="minisearch-path" type="checkbox" name="path" value='"/dokuwiki/inc/Utf8/"' /> current directory</label></li> </ul><input id="minisearch-project" type="hidden" name="project" value="dokuwiki" /><input type="hidden" id="contextpath" value="" /> </div> </form> <script type="text/javascript">/* <![CDATA[ */ document.domReady.push(function() { domReadyMenu(true); }); /* ]]> */ </script> </header> <div id="content"> <script type="text/javascript">/* <![CDATA[ */ document.pageReady.push(function() { pageReadyList();}); /* ]]> */</script> <div id="src"> <pre><a class="l" name="1" href="#1">1</a><strong><?php</strong> <a class="l" name="2" href="#2">2</a> <a class="l" name="3" href="#3">3</a><b>namespace</b> <a href="/s?defs=dokuwiki&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">dokuwiki</a>\<a href="/s?defs=Utf8&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Utf8</a>; <a class="l" name="4" href="#4">4</a> <a class="l" name="5" href="#5">5</a><span class="c">/**</span> <a class="l" name="6" href="#6">6</a><span class="c"> * UTF-8 aware equivalents to PHP's string functions</span> <a class="l" name="7" href="#7">7</a><span class="c"> */</span> <a class="l" name="8" href="#8">8</a><b>class</b> <a href="/s?defs=PhpString&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">PhpString</a> <a class="l" name="9" href="#9">9</a>{ <a class="hl" name="10" href="#10">10</a> <span class="c">/**</span> <a class="l" name="11" href="#11">11</a><span class="c"> * A locale independent basename() implementation</span> <a class="l" name="12" href="#12">12</a><span class="c"> *</span> <a class="l" name="13" href="#13">13</a><span class="c"> * works around a bug in PHP's basename() implementation</span> <a class="l" name="14" href="#14">14</a><span class="c"> *</span> <a class="l" name="15" href="#15">15</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a> A path</span> <a class="l" name="16" href="#16">16</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=suffix&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">suffix</a> If the name component ends in suffix this will also be cut off</span> <a class="l" name="17" href="#17">17</a><span class="c"> * <strong>@return</strong> <b>string</b></span> <a class="l" name="18" href="#18">18</a><span class="c"> * <strong>@link</strong> <a href="https://bugs.php.net/bug.php?id=37738">https://bugs.php.net/bug.php?id=37738</a></span> <a class="l" name="19" href="#19">19</a><span class="c"> *</span> <a class="hl" name="20" href="#20">20</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=basename&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">basename</a>()</span> <a class="l" name="21" href="#21">21</a><span class="c"> */</span> <a class="l" name="22" href="#22">22</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=basename&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">basename</a>($<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a>, $<a href="/s?defs=suffix&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">suffix</a> = <span class="s">''</span>) <a class="l" name="23" href="#23">23</a> { <a class="l" name="24" href="#24">24</a> $<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a> = <a href="/s?defs=trim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">trim</a>($<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a>, <span class="s">'<strong>\\</strong>/'</span>); <a class="l" name="25" href="#25">25</a> $<a href="/s?defs=rpos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rpos</a> = <a href="/s?defs=max&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">max</a>(<a href="/s?defs=strrpos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strrpos</a>($<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a>, <span class="s">'/'</span>), <a href="/s?defs=strrpos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strrpos</a>($<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a>, <span class="s">'<strong>\\</strong>'</span>)); <a class="l" name="26" href="#26">26</a> <b>if</b> ($<a href="/s?defs=rpos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rpos</a>) { <a class="l" name="27" href="#27">27</a> $<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a> = <a href="/s?defs=substr&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">substr</a>($<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a>, $<a href="/s?defs=rpos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rpos</a> + <span class="n">1</span>); <a class="l" name="28" href="#28">28</a> } <a class="l" name="29" href="#29">29</a> <a class="hl" name="30" href="#30">30</a> $<a href="/s?defs=suflen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">suflen</a> = <a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>($<a href="/s?defs=suffix&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">suffix</a>); <a class="l" name="31" href="#31">31</a> <b>if</b> ($<a href="/s?defs=suflen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">suflen</a> && <a href="/s?defs=str_ends_with&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str_ends_with</a>($<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a>, $<a href="/s?defs=suffix&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">suffix</a>)) { <a class="l" name="32" href="#32">32</a> $<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a> = <a href="/s?defs=substr&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">substr</a>($<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a>, <span class="n">0</span>, -$<a href="/s?defs=suflen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">suflen</a>); <a class="l" name="33" href="#33">33</a> } <a class="l" name="34" href="#34">34</a> <a class="l" name="35" href="#35">35</a> <b>return</b> $<a href="/s?defs=path&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">path</a>; <a class="l" name="36" href="#36">36</a> } <a class="l" name="37" href="#37">37</a> <a class="l" name="38" href="#38">38</a> <span class="c">/**</span> <a class="l" name="39" href="#39">39</a><span class="c"> * Unicode aware replacement for strlen()</span> <a class="hl" name="40" href="#40">40</a><span class="c"> *</span> <a class="l" name="41" href="#41">41</a><span class="c"> * utf8_decode() converts characters that are not in ISO-8859-1</span> <a class="l" name="42" href="#42">42</a><span class="c"> * to '?', which, for the purpose of counting, is alright</span> <a class="l" name="43" href="#43">43</a><span class="c"> *</span> <a class="l" name="44" href="#44">44</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a></span> <a class="l" name="45" href="#45">45</a><span class="c"> * <strong>@return</strong> <b>int</b></span> <a class="l" name="46" href="#46">46</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=utf8_decode&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">utf8_decode</a>()</span> <a class="l" name="47" href="#47">47</a><span class="c"> *</span> <a class="l" name="48" href="#48">48</a><span class="c"> * <strong>@author</strong> <chernyshevsky at hotmail dot com></span> <a class="l" name="49" href="#49">49</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>()</span> <a class="hl" name="50" href="#50">50</a><span class="c"> */</span> <a class="l" name="51" href="#51">51</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>) <a class="l" name="52" href="#52">52</a> { <a class="l" name="53" href="#53">53</a> <b>if</b> (<a href="/s?defs=UTF8_MBSTRING&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">UTF8_MBSTRING</a>) { <a class="l" name="54" href="#54">54</a> <b>return</b> <a href="/s?defs=mb_strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">mb_strlen</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>, <span class="s">'UTF-8'</span>); <a class="l" name="55" href="#55">55</a> } <a class="l" name="56" href="#56">56</a> <a class="l" name="57" href="#57">57</a> <b>if</b> (<a href="/s?defs=function_exists&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">function_exists</a>(<span class="s">'iconv_strlen'</span>)) { <a class="l" name="58" href="#58">58</a> <b>return</b> <a href="/s?defs=iconv_strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">iconv_strlen</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>, <span class="s">'UTF-8'</span>); <a class="l" name="59" href="#59">59</a> } <a class="hl" name="60" href="#60">60</a> <a class="l" name="61" href="#61">61</a> <span class="c">// utf8_decode is deprecated</span> <a class="l" name="62" href="#62">62</a> <b>if</b> (<a href="/s?defs=function_exists&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">function_exists</a>(<span class="s">'utf8_decode'</span>)) { <a class="l" name="63" href="#63">63</a> <b>return</b> <a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>(<a href="/s?defs=utf8_decode&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">utf8_decode</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>)); <a class="l" name="64" href="#64">64</a> } <a class="l" name="65" href="#65">65</a> <a class="l" name="66" href="#66">66</a> <b>return</b> <a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>); <a class="l" name="67" href="#67">67</a> } <a class="l" name="68" href="#68">68</a> <a class="l" name="69" href="#69">69</a> <span class="c">/**</span> <a class="hl" name="70" href="#70">70</a><span class="c"> * UTF-8 aware alternative to substr</span> <a class="l" name="71" href="#71">71</a><span class="c"> *</span> <a class="l" name="72" href="#72">72</a><span class="c"> * Return part of a string given character offset (and optionally length)</span> <a class="l" name="73" href="#73">73</a><span class="c"> *</span> <a class="l" name="74" href="#74">74</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a></span> <a class="l" name="75" href="#75">75</a><span class="c"> * <strong>@param</strong> <b>int</b> $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> number of UTF-8 characters offset (from left)</span> <a class="l" name="76" href="#76">76</a><span class="c"> * <strong>@param</strong> <b>int</b> $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> (optional) length in UTF-8 characters from offset</span> <a class="l" name="77" href="#77">77</a><span class="c"> * <strong>@return</strong> <b>string</b></span> <a class="l" name="78" href="#78">78</a><span class="c"> * <strong>@author</strong> Harry Fuecks <hfuecks@gmail.com></span> <a class="l" name="79" href="#79">79</a><span class="c"> * <strong>@author</strong> Chris Smith <chris@jalakai.co.uk></span> <a class="hl" name="80" href="#80">80</a><span class="c"> *</span> <a class="l" name="81" href="#81">81</a><span class="c"> */</span> <a class="l" name="82" href="#82">82</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=substr&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">substr</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>, $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a>, $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> = <a href="/s?defs=null&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">null</a>) <a class="l" name="83" href="#83">83</a> { <a class="l" name="84" href="#84">84</a> <b>if</b> (<a href="/s?defs=UTF8_MBSTRING&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">UTF8_MBSTRING</a>) { <a class="l" name="85" href="#85">85</a> <b>if</b> ($<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> === <a href="/s?defs=null&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">null</a>) { <a class="l" name="86" href="#86">86</a> <b>return</b> <a href="/s?defs=mb_substr&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">mb_substr</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>, $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a>); <a class="l" name="87" href="#87">87</a> } <a class="l" name="88" href="#88">88</a> <a class="l" name="89" href="#89">89</a> <b>return</b> <a href="/s?defs=mb_substr&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">mb_substr</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>, $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a>, $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a>); <a class="hl" name="90" href="#90">90</a> } <a class="l" name="91" href="#91">91</a> <a class="l" name="92" href="#92">92</a> <span class="c">/*</span> <a class="l" name="93" href="#93">93</a><span class="c"> * Notes:</span> <a class="l" name="94" href="#94">94</a><span class="c"> *</span> <a class="l" name="95" href="#95">95</a><span class="c"> * no mb string support, so we'll use pcre regex's with 'u' flag</span> <a class="l" name="96" href="#96">96</a><span class="c"> * pcre only supports repetitions of less than 65536, in order to accept up to MAXINT values for</span> <a class="l" name="97" href="#97">97</a><span class="c"> * offset and length, we'll repeat a group of 65535 characters when needed (ok, up to MAXINT-65536)</span> <a class="l" name="98" href="#98">98</a><span class="c"> *</span> <a class="l" name="99" href="#99">99</a><span class="c"> * substr documentation states false can be returned in some cases (e.g. offset > string length)</span> <a class="hl" name="100" href="#100">100</a><span class="c"> * mb_substr never returns false, it will return an empty string instead.</span> <a class="l" name="101" href="#101">101</a><span class="c"> *</span> <a class="l" name="102" href="#102">102</a><span class="c"> * calculating the number of characters in the string is a relatively expensive operation, so</span> <a class="l" name="103" href="#103">103</a><span class="c"> * we only carry it out when necessary. It isn't necessary for +ve offsets and no specified length</span> <a class="l" name="104" href="#104">104</a><span class="c"> */</span> <a class="l" name="105" href="#105">105</a> <a class="l" name="106" href="#106">106</a> <span class="c">// cast parameters to appropriate types to avoid multiple <a href="/s?path=notices/&project=dokuwiki">notices</a>/<a href="/s?path=notices/warnings&project=dokuwiki">warnings</a></span> <a class="l" name="107" href="#107">107</a> $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a> = (<em>string</em>)$<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>; <span class="c">// generates E_NOTICE for PHP4 objects, but not PHP5 objects</span> <a class="l" name="108" href="#108">108</a> $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> = (<em>int</em>)$<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a>; <a class="l" name="109" href="#109">109</a> <b>if</b> ($<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> !== <a href="/s?defs=null&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">null</a>) $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> = (<em>int</em>)$<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a>; <a class="hl" name="110" href="#110">110</a> <a class="l" name="111" href="#111">111</a> <span class="c">// handle trivial cases</span> <a class="l" name="112" href="#112">112</a> <b>if</b> ($<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> === <span class="n">0</span>) <b>return</b> <span class="s">''</span>; <a class="l" name="113" href="#113">113</a> <b>if</b> ($<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> < <span class="n">0</span> && $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> < <span class="n">0</span> && $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> < $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a>) <b>return</b> <span class="s">''</span>; <a class="l" name="114" href="#114">114</a> <a class="l" name="115" href="#115">115</a> $<a href="/s?defs=offset_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset_pattern</a> = <span class="s">''</span>; <a class="l" name="116" href="#116">116</a> $<a href="/s?defs=length_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length_pattern</a> = <span class="s">''</span>; <a class="l" name="117" href="#117">117</a> <a class="l" name="118" href="#118">118</a> <span class="c">// normalise -ve offsets (we could use a tail anchored pattern, but they are horribly slow!)</span> <a class="l" name="119" href="#119">119</a> <b>if</b> ($<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> < <span class="n">0</span>) { <a class="hl" name="120" href="#120">120</a> $<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a> = <a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>); <span class="c">// see notes</span> <a class="l" name="121" href="#121">121</a> $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> = $<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a> + $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a>; <a class="l" name="122" href="#122">122</a> <b>if</b> ($<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> < <span class="n">0</span>) $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> = <span class="n">0</span>; <a class="l" name="123" href="#123">123</a> } <a class="l" name="124" href="#124">124</a> <a class="l" name="125" href="#125">125</a> <span class="c">// establish a pattern for offset, a non-captured group equal in length to offset</span> <a class="l" name="126" href="#126">126</a> <b>if</b> ($<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> > <span class="n">0</span>) { <a class="l" name="127" href="#127">127</a> $<a href="/s?defs=Ox&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Ox</a> = (<em>int</em>)($<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> / <span class="n">65535</span>); <a class="l" name="128" href="#128">128</a> $<a href="/s?defs=Oy&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Oy</a> = $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> % <span class="n">65535</span>; <a class="l" name="129" href="#129">129</a> <a class="hl" name="130" href="#130">130</a> <b>if</b> ($<a href="/s?defs=Ox&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Ox</a>) $<a href="/s?defs=offset_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset_pattern</a> = <span class="s">'(?:.{65535}){'</span> . $<a href="/s?defs=Ox&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Ox</a> . <span class="s">'}'</span>; <a class="l" name="131" href="#131">131</a> $<a href="/s?defs=offset_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset_pattern</a> = <span class="s">'^(?:'</span> . $<a href="/s?defs=offset_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset_pattern</a> . <span class="s">'.{'</span> . $<a href="/s?defs=Oy&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Oy</a> . <span class="s">'})'</span>; <a class="l" name="132" href="#132">132</a> } <b>else</b> { <a class="l" name="133" href="#133">133</a> $<a href="/s?defs=offset_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset_pattern</a> = <span class="s">'^'</span>; <span class="c">// offset == 0; just anchor the pattern</span> <a class="l" name="134" href="#134">134</a> } <a class="l" name="135" href="#135">135</a> <a class="l" name="136" href="#136">136</a> <span class="c">// establish a pattern for length</span> <a class="l" name="137" href="#137">137</a> <b>if</b> ($<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> === <a href="/s?defs=null&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">null</a>) { <a class="l" name="138" href="#138">138</a> $<a href="/s?defs=length_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length_pattern</a> = <span class="s">'(.*)$'</span>; <span class="c">// the rest of the string</span> <a class="l" name="139" href="#139">139</a> } <b>else</b> { <a class="hl" name="140" href="#140">140</a> <b>if</b> (!<b>isset</b>($<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>)) $<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a> = <a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>); <span class="c">// see notes</span> <a class="l" name="141" href="#141">141</a> <b>if</b> ($<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> > $<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>) <b>return</b> <span class="s">''</span>; <span class="c">// another trivial case</span> <a class="l" name="142" href="#142">142</a> <a class="l" name="143" href="#143">143</a> <b>if</b> ($<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> > <span class="n">0</span>) { <a class="l" name="144" href="#144">144</a> <span class="c">// reduce any length that would go past the end of the string</span> <a class="l" name="145" href="#145">145</a> $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> = <a href="/s?defs=min&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">min</a>($<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a> - $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a>, $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a>); <a class="l" name="146" href="#146">146</a> $<a href="/s?defs=Lx&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Lx</a> = (<em>int</em>)($<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> / <span class="n">65535</span>); <a class="l" name="147" href="#147">147</a> $<a href="/s?defs=Ly&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Ly</a> = $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> % <span class="n">65535</span>; <a class="l" name="148" href="#148">148</a> <span class="c">// +ve length requires ... a captured group of length characters</span> <a class="l" name="149" href="#149">149</a> <b>if</b> ($<a href="/s?defs=Lx&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Lx</a>) $<a href="/s?defs=length_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length_pattern</a> = <span class="s">'(?:.{65535}){'</span> . $<a href="/s?defs=Lx&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Lx</a> . <span class="s">'}'</span>; <a class="hl" name="150" href="#150">150</a> $<a href="/s?defs=length_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length_pattern</a> = <span class="s">'('</span> . $<a href="/s?defs=length_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length_pattern</a> . <span class="s">'.{'</span> . $<a href="/s?defs=Ly&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Ly</a> . <span class="s">'})'</span>; <a class="l" name="151" href="#151">151</a> } <b>elseif</b> ($<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> < <span class="n">0</span>) { <a class="l" name="152" href="#152">152</a> <b>if</b> ($<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> < ($<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> - $<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>)) <b>return</b> <span class="s">''</span>; <a class="l" name="153" href="#153">153</a> $<a href="/s?defs=Lx&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Lx</a> = (<em>int</em>)((-$<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a>) / <span class="n">65535</span>); <a class="l" name="154" href="#154">154</a> $<a href="/s?defs=Ly&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Ly</a> = (-$<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a>) % <span class="n">65535</span>; <a class="l" name="155" href="#155">155</a> <span class="c">// -ve length requires ... capture everything except a group of -length characters</span> <a class="l" name="156" href="#156">156</a> <span class="c">// anchored at the tail-end of the string</span> <a class="l" name="157" href="#157">157</a> <b>if</b> ($<a href="/s?defs=Lx&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Lx</a>) $<a href="/s?defs=length_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length_pattern</a> = <span class="s">'(?:.{65535}){'</span> . $<a href="/s?defs=Lx&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Lx</a> . <span class="s">'}'</span>; <a class="l" name="158" href="#158">158</a> $<a href="/s?defs=length_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length_pattern</a> = <span class="s">'(.*)(?:'</span> . $<a href="/s?defs=length_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length_pattern</a> . <span class="s">'.{'</span> . $<a href="/s?defs=Ly&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Ly</a> . <span class="s">'})$'</span>; <a class="l" name="159" href="#159">159</a> } <a class="hl" name="160" href="#160">160</a> } <a class="l" name="161" href="#161">161</a> <a class="l" name="162" href="#162">162</a> <b>if</b> (!<a href="/s?defs=preg_match&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">preg_match</a>(<span class="s">'#'</span> . $<a href="/s?defs=offset_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset_pattern</a> . $<a href="/s?defs=length_pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length_pattern</a> . <span class="s">'#us'</span>, $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>, $<a href="/s?defs=match&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">match</a>)) <b>return</b> <span class="s">''</span>; <a class="l" name="163" href="#163">163</a> <b>return</b> $<a href="/s?defs=match&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">match</a>[<span class="n">1</span>]; <a class="l" name="164" href="#164">164</a> } <a class="l" name="165" href="#165">165</a> <a class="l" name="166" href="#166">166</a> <span class="c">// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps</span> <a class="l" name="167" href="#167">167</a> <span class="c">/**</span> <a class="l" name="168" href="#168">168</a><span class="c"> * Unicode aware replacement for substr_replace()</span> <a class="l" name="169" href="#169">169</a><span class="c"> *</span> <a class="hl" name="170" href="#170">170</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a> input string</span> <a class="l" name="171" href="#171">171</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=replacement&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">replacement</a> the replacement</span> <a class="l" name="172" href="#172">172</a><span class="c"> * <strong>@param</strong> <b>int</b> $<a href="/s?defs=start&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">start</a> the replacing will begin at the start'th offset into string.</span> <a class="l" name="173" href="#173">173</a><span class="c"> * <strong>@param</strong> <b>int</b> $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> If given and is positive, it represents the length of the portion of string which is</span> <a class="l" name="174" href="#174">174</a><span class="c"> * to be replaced. If length is zero then this function will have the effect of inserting</span> <a class="l" name="175" href="#175">175</a><span class="c"> * replacement into string at the given start offset.</span> <a class="l" name="176" href="#176">176</a><span class="c"> * <strong>@return</strong> <b>string</b></span> <a class="l" name="177" href="#177">177</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=substr_replace&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">substr_replace</a>()</span> <a class="l" name="178" href="#178">178</a><span class="c"> *</span> <a class="l" name="179" href="#179">179</a><span class="c"> * <strong>@author</strong> Andreas Gohr <andi@splitbrain.org></span> <a class="hl" name="180" href="#180">180</a><span class="c"> */</span> <a class="l" name="181" href="#181">181</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=substr_replace&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">substr_replace</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>, $<a href="/s?defs=replacement&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">replacement</a>, $<a href="/s?defs=start&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">start</a>, $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> = <span class="n">0</span>) <a class="l" name="182" href="#182">182</a> { <a class="l" name="183" href="#183">183</a> $<a href="/s?defs=ret&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ret</a> = <span class="s">''</span>; <a class="l" name="184" href="#184">184</a> <b>if</b> ($<a href="/s?defs=start&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">start</a> > <span class="n">0</span>) $<a href="/s?defs=ret&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ret</a> .= <a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=substr&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">substr</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>, <span class="n">0</span>, $<a href="/s?defs=start&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">start</a>); <a class="l" name="185" href="#185">185</a> $<a href="/s?defs=ret&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ret</a> .= $<a href="/s?defs=replacement&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">replacement</a>; <a class="l" name="186" href="#186">186</a> $<a href="/s?defs=ret&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ret</a> .= <a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=substr&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">substr</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>, $<a href="/s?defs=start&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">start</a> + $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a>); <a class="l" name="187" href="#187">187</a> <b>return</b> $<a href="/s?defs=ret&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ret</a>; <a class="l" name="188" href="#188">188</a> } <a class="l" name="189" href="#189">189</a> <span class="c">// phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps</span> <a class="hl" name="190" href="#190">190</a> <a class="l" name="191" href="#191">191</a> <span class="c">/**</span> <a class="l" name="192" href="#192">192</a><span class="c"> * Unicode aware replacement for ltrim()</span> <a class="l" name="193" href="#193">193</a><span class="c"> *</span> <a class="l" name="194" href="#194">194</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a></span> <a class="l" name="195" href="#195">195</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a></span> <a class="l" name="196" href="#196">196</a><span class="c"> * <strong>@return</strong> <b>string</b></span> <a class="l" name="197" href="#197">197</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=ltrim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ltrim</a>()</span> <a class="l" name="198" href="#198">198</a><span class="c"> *</span> <a class="l" name="199" href="#199">199</a><span class="c"> * <strong>@author</strong> Andreas Gohr <andi@splitbrain.org></span> <a class="hl" name="200" href="#200">200</a><span class="c"> */</span> <a class="l" name="201" href="#201">201</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=ltrim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ltrim</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>, $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a> = <span class="s">''</span>) <a class="l" name="202" href="#202">202</a> { <a class="l" name="203" href="#203">203</a> <b>if</b> ($<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a> === <span class="s">''</span>) <b>return</b> <a href="/s?defs=ltrim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ltrim</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>); <a class="l" name="204" href="#204">204</a> <a class="l" name="205" href="#205">205</a> <span class="c">//quote charlist for use in a characterclass</span> <a class="l" name="206" href="#206">206</a> $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a> = <a href="/s?defs=preg_replace&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">preg_replace</a>(<span class="s">'!([<strong>\\</strong><strong>\\</strong><strong>\\</strong>-<strong>\\</strong>]<strong>\\</strong>[/])!'</span>, <span class="s">'<strong>\\</strong>\${1}'</span>, $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a>); <a class="l" name="207" href="#207">207</a> <a class="l" name="208" href="#208">208</a> <b>return</b> <a href="/s?defs=preg_replace&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">preg_replace</a>(<span class="s">'/^['</span> . $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a> . <span class="s">']+/u'</span>, <span class="s">''</span>, $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>); <a class="l" name="209" href="#209">209</a> } <a class="hl" name="210" href="#210">210</a> <a class="l" name="211" href="#211">211</a> <span class="c">/**</span> <a class="l" name="212" href="#212">212</a><span class="c"> * Unicode aware replacement for rtrim()</span> <a class="l" name="213" href="#213">213</a><span class="c"> *</span> <a class="l" name="214" href="#214">214</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a></span> <a class="l" name="215" href="#215">215</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a></span> <a class="l" name="216" href="#216">216</a><span class="c"> * <strong>@return</strong> <b>string</b></span> <a class="l" name="217" href="#217">217</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=rtrim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rtrim</a>()</span> <a class="l" name="218" href="#218">218</a><span class="c"> *</span> <a class="l" name="219" href="#219">219</a><span class="c"> * <strong>@author</strong> Andreas Gohr <andi@splitbrain.org></span> <a class="hl" name="220" href="#220">220</a><span class="c"> */</span> <a class="l" name="221" href="#221">221</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=rtrim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rtrim</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>, $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a> = <span class="s">''</span>) <a class="l" name="222" href="#222">222</a> { <a class="l" name="223" href="#223">223</a> <b>if</b> ($<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a> === <span class="s">''</span>) <b>return</b> <a href="/s?defs=rtrim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rtrim</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>); <a class="l" name="224" href="#224">224</a> <a class="l" name="225" href="#225">225</a> <span class="c">//quote charlist for use in a characterclass</span> <a class="l" name="226" href="#226">226</a> $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a> = <a href="/s?defs=preg_replace&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">preg_replace</a>(<span class="s">'!([<strong>\\</strong><strong>\\</strong><strong>\\</strong>-<strong>\\</strong>]<strong>\\</strong>[/])!'</span>, <span class="s">'<strong>\\</strong>\${1}'</span>, $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a>); <a class="l" name="227" href="#227">227</a> <a class="l" name="228" href="#228">228</a> <b>return</b> <a href="/s?defs=preg_replace&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">preg_replace</a>(<span class="s">'/['</span> . $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a> . <span class="s">']+$/u'</span>, <span class="s">''</span>, $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>); <a class="l" name="229" href="#229">229</a> } <a class="hl" name="230" href="#230">230</a> <a class="l" name="231" href="#231">231</a> <span class="c">/**</span> <a class="l" name="232" href="#232">232</a><span class="c"> * Unicode aware replacement for trim()</span> <a class="l" name="233" href="#233">233</a><span class="c"> *</span> <a class="l" name="234" href="#234">234</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a></span> <a class="l" name="235" href="#235">235</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a></span> <a class="l" name="236" href="#236">236</a><span class="c"> * <strong>@return</strong> <b>string</b></span> <a class="l" name="237" href="#237">237</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=trim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">trim</a>()</span> <a class="l" name="238" href="#238">238</a><span class="c"> *</span> <a class="l" name="239" href="#239">239</a><span class="c"> * <strong>@author</strong> Andreas Gohr <andi@splitbrain.org></span> <a class="hl" name="240" href="#240">240</a><span class="c"> */</span> <a class="l" name="241" href="#241">241</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=trim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">trim</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>, $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a> = <span class="s">''</span>) <a class="l" name="242" href="#242">242</a> { <a class="l" name="243" href="#243">243</a> <b>if</b> ($<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a> === <span class="s">''</span>) <b>return</b> <a href="/s?defs=trim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">trim</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>); <a class="l" name="244" href="#244">244</a> <a class="l" name="245" href="#245">245</a> <b>return</b> <a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=ltrim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ltrim</a>(<a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=rtrim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rtrim</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>, $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a>), $<a href="/s?defs=charlist&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">charlist</a>); <a class="l" name="246" href="#246">246</a> } <a class="l" name="247" href="#247">247</a> <a class="l" name="248" href="#248">248</a> <span class="c">/**</span> <a class="l" name="249" href="#249">249</a><span class="c"> * This is a unicode aware replacement for strtolower()</span> <a class="hl" name="250" href="#250">250</a><span class="c"> *</span> <a class="l" name="251" href="#251">251</a><span class="c"> * Uses mb_string extension if available</span> <a class="l" name="252" href="#252">252</a><span class="c"> *</span> <a class="l" name="253" href="#253">253</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a></span> <a class="l" name="254" href="#254">254</a><span class="c"> * <strong>@return</strong> <b>string</b></span> <a class="l" name="255" href="#255">255</a><span class="c"> * <strong>@see</strong> \dokuwiki\Utf8\PhpString::strtoupper()</span> <a class="l" name="256" href="#256">256</a><span class="c"> *</span> <a class="l" name="257" href="#257">257</a><span class="c"> * <strong>@author</strong> Leo Feyer <leo@typolight.org></span> <a class="l" name="258" href="#258">258</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=strtolower&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strtolower</a>()</span> <a class="l" name="259" href="#259">259</a><span class="c"> */</span> <a class="hl" name="260" href="#260">260</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=strtolower&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strtolower</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>) <a class="l" name="261" href="#261">261</a> { <a class="l" name="262" href="#262">262</a> <b>if</b> ($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a> === <a href="/s?defs=null&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">null</a>) <b>return</b> <span class="s">''</span>; <span class="c">// pre-8.1 behaviour</span> <a class="l" name="263" href="#263">263</a> <b>if</b> (<a href="/s?defs=UTF8_MBSTRING&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">UTF8_MBSTRING</a>) { <a class="l" name="264" href="#264">264</a> <b>if</b> (<a href="/s?defs=class_exists&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">class_exists</a>(<span class="s">'Normalizer'</span>, $<a href="/s?defs=autoload&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">autoload</a> = <a href="/s?defs=false&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">false</a>)) { <a class="l" name="265" href="#265">265</a> <b>return</b> \<a href="/s?defs=Normalizer&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Normalizer</a>::<a href="/s?defs=normalize&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">normalize</a>(<a href="/s?defs=mb_strtolower&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">mb_strtolower</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>, <span class="s">'utf-8'</span>)); <a class="l" name="266" href="#266">266</a> } <a class="l" name="267" href="#267">267</a> <b>return</b> (<a href="/s?defs=mb_strtolower&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">mb_strtolower</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>, <span class="s">'utf-8'</span>)); <a class="l" name="268" href="#268">268</a> } <a class="l" name="269" href="#269">269</a> <b>return</b> <a href="/s?defs=strtr&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strtr</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>, <a href="/s?defs=Table&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Table</a>::<a href="/s?defs=upperCaseToLowerCase&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">upperCaseToLowerCase</a>()); <a class="hl" name="270" href="#270">270</a> } <a class="l" name="271" href="#271">271</a> <a class="l" name="272" href="#272">272</a> <span class="c">/**</span> <a class="l" name="273" href="#273">273</a><span class="c"> * This is a unicode aware replacement for strtoupper()</span> <a class="l" name="274" href="#274">274</a><span class="c"> *</span> <a class="l" name="275" href="#275">275</a><span class="c"> * Uses mb_string extension if available</span> <a class="l" name="276" href="#276">276</a><span class="c"> *</span> <a class="l" name="277" href="#277">277</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a></span> <a class="l" name="278" href="#278">278</a><span class="c"> * <strong>@return</strong> <b>string</b></span> <a class="l" name="279" href="#279">279</a><span class="c"> * <strong>@see</strong> \dokuwiki\Utf8\PhpString::strtoupper()</span> <a class="hl" name="280" href="#280">280</a><span class="c"> *</span> <a class="l" name="281" href="#281">281</a><span class="c"> * <strong>@author</strong> Leo Feyer <leo@typolight.org></span> <a class="l" name="282" href="#282">282</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=strtoupper&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strtoupper</a>()</span> <a class="l" name="283" href="#283">283</a><span class="c"> */</span> <a class="l" name="284" href="#284">284</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=strtoupper&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strtoupper</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>) <a class="l" name="285" href="#285">285</a> { <a class="l" name="286" href="#286">286</a> <b>if</b> (<a href="/s?defs=UTF8_MBSTRING&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">UTF8_MBSTRING</a>) <b>return</b> <a href="/s?defs=mb_strtoupper&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">mb_strtoupper</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>, <span class="s">'utf-8'</span>); <a class="l" name="287" href="#287">287</a> <a class="l" name="288" href="#288">288</a> <b>return</b> <a href="/s?defs=strtr&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strtr</a>($<a href="/s?defs=string&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">string</a>, <a href="/s?defs=Table&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Table</a>::<a href="/s?defs=lowerCaseToUpperCase&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">lowerCaseToUpperCase</a>()); <a class="l" name="289" href="#289">289</a> } <a class="hl" name="290" href="#290">290</a> <a class="l" name="291" href="#291">291</a> <a class="l" name="292" href="#292">292</a> <span class="c">/**</span> <a class="l" name="293" href="#293">293</a><span class="c"> * UTF-8 aware alternative to ucfirst</span> <a class="l" name="294" href="#294">294</a><span class="c"> * Make a string's first character uppercase</span> <a class="l" name="295" href="#295">295</a><span class="c"> *</span> <a class="l" name="296" href="#296">296</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a></span> <a class="l" name="297" href="#297">297</a><span class="c"> * <strong>@return</strong> <b>string</b> with first character as upper case (if applicable)</span> <a class="l" name="298" href="#298">298</a><span class="c"> * <strong>@author</strong> Harry Fuecks</span> <a class="l" name="299" href="#299">299</a><span class="c"> *</span> <a class="hl" name="300" href="#300">300</a><span class="c"> */</span> <a class="l" name="301" href="#301">301</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=ucfirst&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ucfirst</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>) <a class="l" name="302" href="#302">302</a> { <a class="l" name="303" href="#303">303</a> <b>switch</b> (<a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>)) { <a class="l" name="304" href="#304">304</a> <b>case</b> <span class="n">0</span>: <a class="l" name="305" href="#305">305</a> <b>return</b> <span class="s">''</span>; <a class="l" name="306" href="#306">306</a> <b>case</b> <span class="n">1</span>: <a class="l" name="307" href="#307">307</a> <b>return</b> <a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=strtoupper&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strtoupper</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>); <a class="l" name="308" href="#308">308</a> <b>default</b>: <a class="l" name="309" href="#309">309</a> <a href="/s?defs=preg_match&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">preg_match</a>(<span class="s">'/^(.{1})(.*)$/us'</span>, $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>, $<a href="/s?defs=matches&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">matches</a>); <a class="hl" name="310" href="#310">310</a> <b>return</b> <a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=strtoupper&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strtoupper</a>($<a href="/s?defs=matches&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">matches</a>[<span class="n">1</span>]) . $<a href="/s?defs=matches&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">matches</a>[<span class="n">2</span>]; <a class="l" name="311" href="#311">311</a> } <a class="l" name="312" href="#312">312</a> } <a class="l" name="313" href="#313">313</a> <a class="l" name="314" href="#314">314</a> <span class="c">/**</span> <a class="l" name="315" href="#315">315</a><span class="c"> * UTF-8 aware alternative to ucwords</span> <a class="l" name="316" href="#316">316</a><span class="c"> * Uppercase the first character of each word in a string</span> <a class="l" name="317" href="#317">317</a><span class="c"> *</span> <a class="l" name="318" href="#318">318</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a></span> <a class="l" name="319" href="#319">319</a><span class="c"> * <strong>@return</strong> <b>string</b> with first char of each word uppercase</span> <a class="hl" name="320" href="#320">320</a><span class="c"> * <strong>@author</strong> Harry Fuecks</span> <a class="l" name="321" href="#321">321</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=http&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">http</a>://<a href="/s?path=/php.net/&project=dokuwiki">php.net</a>/<a href="/s?path=/php.net/ucwords&project=dokuwiki">ucwords</a></span> <a class="l" name="322" href="#322">322</a><span class="c"> *</span> <a class="l" name="323" href="#323">323</a><span class="c"> */</span> <a class="l" name="324" href="#324">324</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=ucwords&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ucwords</a>($<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>) <a class="l" name="325" href="#325">325</a> { <a class="l" name="326" href="#326">326</a> <span class="c">// Note: [\x0c\x09\x0b\x0a\x0d\x20] matches;</span> <a class="l" name="327" href="#327">327</a> <span class="c">// form feeds, horizontal tabs, vertical tabs, linefeeds and carriage returns</span> <a class="l" name="328" href="#328">328</a> <span class="c">// This corresponds to the definition of a "word" defined at <a href="http://php.net/ucwords">http://php.net/ucwords</a></span> <a class="l" name="329" href="#329">329</a> $<a href="/s?defs=pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pattern</a> = <span class="s">'/(^|([\x0c\x09\x0b\x0a\x0d\x20]+))([^\x0c\x09\x0b\x0a\x0d\x20]{1})[^\x0c\x09\x0b\x0a\x0d\x20]*/u'</span>; <a class="hl" name="330" href="#330">330</a> <a class="l" name="331" href="#331">331</a> <b>return</b> <a href="/s?defs=preg_replace_callback&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">preg_replace_callback</a>( <a class="l" name="332" href="#332">332</a> $<a href="/s?defs=pattern&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pattern</a>, <a class="l" name="333" href="#333">333</a> <b>function</b> ($<a href="/s?defs=matches&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">matches</a>) { <a class="l" name="334" href="#334">334</a> $<a href="/s?defs=leadingws&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">leadingws</a> = $<a href="/s?defs=matches&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">matches</a>[<span class="n">2</span>]; <a class="l" name="335" href="#335">335</a> $<a href="/s?defs=ucfirst&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ucfirst</a> = <a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=strtoupper&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strtoupper</a>($<a href="/s?defs=matches&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">matches</a>[<span class="n">3</span>]); <a class="l" name="336" href="#336">336</a> $<a href="/s?defs=ucword&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ucword</a> = <a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=substr_replace&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">substr_replace</a>(<a href="/s?defs=ltrim&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ltrim</a>($<a href="/s?defs=matches&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">matches</a>[<span class="n">0</span>]), $<a href="/s?defs=ucfirst&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ucfirst</a>, <span class="n">0</span>, <span class="n">1</span>); <a class="l" name="337" href="#337">337</a> <b>return</b> $<a href="/s?defs=leadingws&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">leadingws</a> . $<a href="/s?defs=ucword&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ucword</a>; <a class="l" name="338" href="#338">338</a> }, <a class="l" name="339" href="#339">339</a> $<a href="/s?defs=str&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a> <a class="hl" name="340" href="#340">340</a> ); <a class="l" name="341" href="#341">341</a> } <a class="l" name="342" href="#342">342</a> <a class="l" name="343" href="#343">343</a> <span class="c">/**</span> <a class="l" name="344" href="#344">344</a><span class="c"> * This is an Unicode aware replacement for strpos</span> <a class="l" name="345" href="#345">345</a><span class="c"> *</span> <a class="l" name="346" href="#346">346</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=haystack&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">haystack</a></span> <a class="l" name="347" href="#347">347</a><span class="c"> * <strong>@param</strong> <b>string</b> $<a href="/s?defs=needle&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">needle</a></span> <a class="l" name="348" href="#348">348</a><span class="c"> * <strong>@param</strong> <b>integer</b> $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a></span> <a class="l" name="349" href="#349">349</a><span class="c"> * <strong>@return</strong> <b>integer</b></span> <a class="hl" name="350" href="#350">350</a><span class="c"> * <strong>@author</strong> Leo Feyer <leo@typolight.org></span> <a class="l" name="351" href="#351">351</a><span class="c"> * <strong>@see</strong> <a href="/s?defs=strpos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strpos</a>()</span> <a class="l" name="352" href="#352">352</a><span class="c"> *</span> <a class="l" name="353" href="#353">353</a><span class="c"> */</span> <a class="l" name="354" href="#354">354</a> <b>public</b> <b>static</b> <b>function</b> <a href="/s?defs=strpos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strpos</a>($<a href="/s?defs=haystack&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">haystack</a>, $<a href="/s?defs=needle&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">needle</a>, $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> = <span class="n">0</span>) <a class="l" name="355" href="#355">355</a> { <a class="l" name="356" href="#356">356</a> $<a href="/s?defs=comp&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">comp</a> = <span class="n">0</span>; <a class="l" name="357" href="#357">357</a> $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> = <a href="/s?defs=null&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">null</a>; <a class="l" name="358" href="#358">358</a> <a class="l" name="359" href="#359">359</a> <b>while</b> ($<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> === <a href="/s?defs=null&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">null</a> || $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> < $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a>) { <a class="hl" name="360" href="#360">360</a> $<a href="/s?defs=pos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pos</a> = <a href="/s?defs=strpos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strpos</a>($<a href="/s?defs=haystack&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">haystack</a>, $<a href="/s?defs=needle&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">needle</a>, $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a> + $<a href="/s?defs=comp&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">comp</a>); <a class="l" name="361" href="#361">361</a> <a class="l" name="362" href="#362">362</a> <b>if</b> ($<a href="/s?defs=pos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pos</a> === <a href="/s?defs=false&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">false</a>) <a class="l" name="363" href="#363">363</a> <b>return</b> <a href="/s?defs=false&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">false</a>; <a class="l" name="364" href="#364">364</a> <a class="l" name="365" href="#365">365</a> $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> = <a href="/s?defs=self&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a>::<a href="/s?defs=strlen&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">strlen</a>(<a href="/s?defs=substr&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">substr</a>($<a href="/s?defs=haystack&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">haystack</a>, <span class="n">0</span>, $<a href="/s?defs=pos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pos</a>)); <a class="l" name="366" href="#366">366</a> <a class="l" name="367" href="#367">367</a> <b>if</b> ($<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a> < $<a href="/s?defs=offset&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">offset</a>) <a class="l" name="368" href="#368">368</a> $<a href="/s?defs=comp&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">comp</a> = $<a href="/s?defs=pos&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pos</a> - $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a>; <a class="l" name="369" href="#369">369</a> } <a class="hl" name="370" href="#370">370</a> <a class="l" name="371" href="#371">371</a> <b>return</b> $<a href="/s?defs=length&project=dokuwiki" class="intelliWindow-symbol" data-definition-place="undefined-in-file">length</a>; <a class="l" name="372" href="#372">372</a> } <a class="l" name="373" href="#373">373</a>} <a class="l" name="374" href="#374">374</a></pre> </div><footer id="footer"> <p><a href="https://oracle.github.io/opengrok/" class="link-no-decoration" title="Served by OpenGrok (1.7.31 - 6333fd7)"> <span id="served-by">served by </span><span class="logo logo-gray-color">{</span><span class="logo logo-blue-color">Open</span><span class="logo logo-gray-color">Grok</span> </a></p> <p>Last Index Update: Thu Jul 13 10:31:41 UTC 2023</p> <!-- Include for DokuWiki site wide top bar --> <style type="text/css"> @media screen { body { padding-top: 30px; } #global__header { position: absolute; top: 0; left: 0; text-align: left; vertical-align: middle; line-height: 1.5; background-color: #333; box-shadow: 0 0 8px rgba(0,0,0,0.5); width: 100%; margin: 0; padding: 5px 20px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; white-space: nowrap; overflow: hidden; } #global__header h2 { position: absolute; left: -99999em; top: 0; overflow: hidden; display: inline; } #global__header ul, #global__header li { margin: 0; padding: 0; list-style: none; display: inline; line-height: 1.5; } #global__header a { color: #bbb; text-decoration: none; margin-right: 20px; font-size: 14px; font-weight: normal; } #global__header a:hover, #global__header a:active, #global__header a:focus { color: #fff; text-decoration: underline; } #global__header form { float: right; margin: 0 0 0 20px; } #global__header input { background-color: #333; background-image: none; border: 1px solid #bbb; color: #fff; box-shadow: none; border-radius: 2px; margin: 0; line-height: normal; padding: 1px 0 1px 0; height: auto; } #global__header input.button { border: none; color: #bbb; } #global__header input.button:hover, #global__header input.button:active, #global__header input.button:focus { color: #fff; text-decoration: underline; } } /* /@media */ @media only screen and (min-width: 601px) { /* changes specific for www.dokuwiki.org */ #dokuwiki__header { padding-top: 3em; } #dokuwiki__usertools { top: 3em; } /* changes specific for bugs.dokuwiki.org */ div#container div#showtask { top: 40px; } } /* /@media */ @media only screen and (max-width: 600px) { body { padding-top: 0; } #global__header { position: static; white-space: normal; overflow: auto; } #global__header form { float: none; display: block; margin: 0 0 .4em; } } /* /@media */ @media print { #global__header { display: none; } } /* /@media */ </style> <div id="global__header"> <h2>Global DokuWiki Links</h2> <form method="get" action="https://search.dokuwiki.org/" target="_top"> <input type="text" name="q" title="Search all DokuWiki sites at once" class="input" /> <input type="submit" title="Search all DokuWiki sites at once" value="Search" class="button" /> </form> <ul> <li><a href="https://download.dokuwiki.org" title="Download the latest release" target="_top">Download</a></li> <li><a href="https://www.dokuwiki.org" title="Read the DokuWiki documentation" target="_top">Wiki</a></li> <li><a href="https://forum.dokuwiki.org" title="Ask questions in the DokuWiki forum" target="_top">Forum</a></li> <li><a href="https://irc.dokuwiki.org" title="Check IRC chat logs or join the chat" target="_top">IRC</a></li> <li><a href="https://github.com/splitbrain/dokuwiki/issues" title="Report and track bugs" target="_top">Bugs</a></li> <li><a href="https://translate.dokuwiki.org/" title="Help translating the DokuWiki interface" target="_top">Translate</a></li> <li><a href="https://github.com/splitbrain/dokuwiki" title="Access the most recent git commits" target="_top">Git</a></li> <li><a href="https://xref.dokuwiki.org/reference/dokuwiki/" title="Cross-Reference of the DokuWiki source code" target="_top">XRef</a></li> <li><a href="https://codesearch.dokuwiki.org/" title="Search through the sources of DokuWiki, plugins and templates" target="_top">Code Search</a></li> </ul> </div> <!-- end of DokuWiki top bar include --> </div></footer> </div> <script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js" data-priority="10"></script> <script type="text/javascript" src="/js/jquery-ui-1.12.1-custom.min.js" data-priority="11"></script> <script type="text/javascript" src="/webjars/tablesorter/2.31.3/dist/js/jquery.tablesorter.min.js" data-priority="12"></script> <script type="text/javascript" src="/js/tablesorter-parsers-0.0.3.min.js" data-priority="13"></script> <script type="text/javascript" src="/js/searchable-option-list-2.0.15.min.js" data-priority="14"></script> <script type="text/javascript" src="/js/utils-0.0.45.min.js" data-priority="15"></script> <script type="text/javascript" src="/js/jquery.caret-1.5.2.min.js" data-priority="25"></script> </body> </html>