Clarify what the 'width' in mb_strimwidth means

Co-authored-by: Alex Dowad <alexinbeijing@gmail.com>

Closes GH-124.
This commit is contained in:
Christoph M. Becker 2021-02-15 17:12:04 +01:00
parent 8b7fb1d4ac
commit a69f6cf5d2
2 changed files with 31 additions and 1 deletions

View file

@ -17,7 +17,11 @@
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Truncates <type>string</type> <parameter>string</parameter> to specified <parameter>width</parameter>.
Truncates <type>string</type> <parameter>string</parameter> to specified <parameter>width</parameter>,
where halfwidth characters count as <literal>1</literal>, and fullwidth
characters count as <literal>2</literal>.
See <link xlink:href="&url.unicode.reports.tr;11/">&url.unicode.reports.tr;11/</link>
for details regarding East Asian character widths.
</para>
</refsect1>

View file

@ -17,6 +17,8 @@
Returns the width of <type>string</type> <parameter>string</parameter>,
where halfwidth characters count as <literal>1</literal>, and fullwidth
characters count as <literal>2</literal>.
See <link xlink:href="&url.unicode.reports.tr;11/">&url.unicode.reports.tr;11/</link>
for details regarding East Asian character widths.
</para>
<para>
The fullwidth characters are:
@ -109,6 +111,30 @@
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example xml:id="mb-strwidth.example.basic">
<title><function>mb_strwidth</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
var_dump(
mb_strwidth('a'), // LATIN SMALL LETTER A
mb_strwidth("\u{ff41}") // FULLWIDTH LATIN SMALL LETTER A
);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(1)
int(2)
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>