mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-19 06:16:58 +08:00
97 lines
4.5 KiB
HTML
97 lines
4.5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Get string length in grapheme units</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.grapheme-strlen" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">grapheme_strlen</h1>
|
|
<p class="verinfo">(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)</p><p class="refpurpose"><span class="refname">grapheme_strlen</span> — <span class="dc-title">Get string length in grapheme units</span></p>
|
|
|
|
</div>
|
|
<div class="refsect1 description" id="refsect1-function.grapheme-strlen-description">
|
|
<h3 class="title">说明</h3>
|
|
<p class="para">过程化风格</p>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>grapheme_strlen</strong></span>
|
|
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$input</code></span>
|
|
) : <span class="type">int</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Get string length in grapheme units (not bytes or characters)
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.grapheme-strlen-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">input</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The string being measured for length. It must be a valid UTF-8 string.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.grapheme-strlen-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
The length of the string on success, and 0 if the string is empty.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.grapheme-strlen-examples">
|
|
<h3 class="title">范例</h3>
|
|
<div class="example" id="example-3096">
|
|
<p><strong>Example #1 <span class="function"><strong>grapheme_strlen()</strong></span> example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /><br />$char_a_ring_nfd </span><span style="color: #007700">= </span><span style="color: #DD0000">"a\xCC\x8A"</span><span style="color: #007700">; </span><span style="color: #FF8000">// 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"<br /></span><span style="color: #0000BB">$char_o_diaeresis_nfd </span><span style="color: #007700">= </span><span style="color: #DD0000">"o\xCC\x88"</span><span style="color: #007700">; </span><span style="color: #FF8000">// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"<br /><br /></span><span style="color: #007700">print </span><span style="color: #0000BB">grapheme_strlen</span><span style="color: #007700">( </span><span style="color: #DD0000">'abc' </span><span style="color: #007700">. </span><span style="color: #0000BB">$char_a_ring_nfd </span><span style="color: #007700">. </span><span style="color: #0000BB">$char_o_diaeresis_nfd </span><span style="color: #007700">. </span><span style="color: #0000BB">$char_a_ring_nfd</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
<p class="para">以上例程会输出:</p>
|
|
<div class="example-contents screen">
|
|
<div class="cdata"><pre>
|
|
6
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.grapheme-strlen-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member">
|
|
<a href="http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries" class="link external">»
|
|
Unicode Text Segmentation: Grapheme Cluster Boundaries
|
|
</a>
|
|
</li>
|
|
<li class="member"><span class="function"><a href="iconv_strlen.html" class="function" rel="rdfs-seeAlso">iconv_strlen()</a> - 返回字符串的字符数统计</span></li>
|
|
<li class="member"><span class="function"><a href="mb_strlen.html" class="function" rel="rdfs-seeAlso">mb_strlen()</a> - 获取字符串的长度</span></li>
|
|
<li class="member"><span class="function"><a href="strlen.html" class="function" rel="rdfs-seeAlso">strlen()</a> - 获取字符串长度</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
</div></div></div></body></html> |