reference/mbstring/functions/mb-strwidth.xml
64f2f1c70d2f42507d9c624e09dcf486ceca7be5
...
...
@@ -10,49 +10,58 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>int</type><methodname>mb_strwidth</methodname>
13
-
<methodparam><type>string</type><parameter>str</parameter></methodparam>
14
-
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter><initializer>mb_internal_encoding()</initializer></methodparam>
13
+
<methodparam><type>string</type><parameter>string</parameter></methodparam>
14
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
-
Returns the width of <type>string</type> <parameter>str</parameter>.
17
+
Returns the width of <type>string</type> <parameter>string</parameter>,
18
+
where halfwidth characters count as <literal>1</literal>, and fullwidth
19
+
characters count as <literal>2</literal>.
20
+
See <link xlink:href="&url.unicode.reports.tr;11/">&url.unicode.reports.tr;11/</link>
21
+
for details regarding East Asian character widths.
18
22
</para>
19
23
<para>
20
-
Multi-byte characters are usually twice the width of single byte characters.
21
-
</para>
22
-
<para>
23
-
<table>
24
-
<title>Characters width</title>
25
-
<tgroup cols="2">
26
-
<thead>
27
-
<row>
28
-
<entry>Chars</entry>
29
-
<entry>Width</entry>
30
-
</row>
31
-
</thead>
32
-
<tbody>
33
-
<row>
34
-
<entry>U+0000 - U+0019</entry>
35
-
<entry>0</entry>
36
-
</row>
37
-
<row>
38
-
<entry>U+0020 - U+1FFF</entry>
39
-
<entry>1</entry>
40
-
</row>
41
-
<row>
42
-
<entry>U+2000 - U+FF60</entry>
43
-
<entry>2</entry>
44
-
</row>
45
-
<row>
46
-
<entry>U+FF61 - U+FF9F</entry>
47
-
<entry>1</entry>
48
-
</row>
49
-
<row>
50
-
<entry>U+FFA0 - </entry>
51
-
<entry>2</entry>
52
-
</row>
53
-
</tbody>
54
-
</tgroup>
55
-
</table>
24
+
The fullwidth characters are:
25
+
<literal>U+1100</literal>-<literal>U+115F</literal>,
26
+
<literal>U+11A3</literal>-<literal>U+11A7</literal>,
27
+
<literal>U+11FA</literal>-<literal>U+11FF</literal>,
28
+
<literal>U+2329</literal>-<literal>U+232A</literal>,
29
+
<literal>U+2E80</literal>-<literal>U+2E99</literal>,
30
+
<literal>U+2E9B</literal>-<literal>U+2EF3</literal>,
31
+
<literal>U+2F00</literal>-<literal>U+2FD5</literal>,
32
+
<literal>U+2FF0</literal>-<literal>U+2FFB</literal>,
33
+
<literal>U+3000</literal>-<literal>U+303E</literal>,
34
+
<literal>U+3041</literal>-<literal>U+3096</literal>,
35
+
<literal>U+3099</literal>-<literal>U+30FF</literal>,
36
+
<literal>U+3105</literal>-<literal>U+312D</literal>,
37
+
<literal>U+3131</literal>-<literal>U+318E</literal>,
38
+
<literal>U+3190</literal>-<literal>U+31BA</literal>,
39
+
<literal>U+31C0</literal>-<literal>U+31E3</literal>,
40
+
<literal>U+31F0</literal>-<literal>U+321E</literal>,
41
+
<literal>U+3220</literal>-<literal>U+3247</literal>,
42
+
<literal>U+3250</literal>-<literal>U+32FE</literal>,
43
+
<literal>U+3300</literal>-<literal>U+4DBF</literal>,
44
+
<literal>U+4E00</literal>-<literal>U+A48C</literal>,
45
+
<literal>U+A490</literal>-<literal>U+A4C6</literal>,
46
+
<literal>U+A960</literal>-<literal>U+A97C</literal>,
47
+
<literal>U+AC00</literal>-<literal>U+D7A3</literal>,
48
+
<literal>U+D7B0</literal>-<literal>U+D7C6</literal>,
49
+
<literal>U+D7CB</literal>-<literal>U+D7FB</literal>,
50
+
<literal>U+F900</literal>-<literal>U+FAFF</literal>,
51
+
<literal>U+FE10</literal>-<literal>U+FE19</literal>,
52
+
<literal>U+FE30</literal>-<literal>U+FE52</literal>,
53
+
<literal>U+FE54</literal>-<literal>U+FE66</literal>,
54
+
<literal>U+FE68</literal>-<literal>U+FE6B</literal>,
55
+
<literal>U+FF01</literal>-<literal>U+FF60</literal>,
56
+
<literal>U+FFE0</literal>-<literal>U+FFE6</literal>,
57
+
<literal>U+1B000</literal>-<literal>U+1B001</literal>,
58
+
<literal>U+1F200</literal>-<literal>U+1F202</literal>,
59
+
<literal>U+1F210</literal>-<literal>U+1F23A</literal>,
60
+
<literal>U+1F240</literal>-<literal>U+1F248</literal>,
61
+
<literal>U+1F250</literal>-<literal>U+1F251</literal>,
62
+
<literal>U+20000</literal>-<literal>U+2FFFD</literal>,
63
+
<literal>U+30000</literal>-<literal>U+3FFFD</literal>.
64
+
All other characters are halfwidth characters.
56
65
</para>
57
66
</refsect1>
58
67

...
...
@@ -61,7 +70,7 @@
61
70
<para>
62
71
<variablelist>
63
72
<varlistentry>
64
-
<term><parameter>str</parameter></term>
73
+
<term><parameter>string</parameter></term>
65
74
<listitem>
66
75
<para>
67
76
The <type>string</type> being decoded.
...
...
@@ -81,10 +90,51 @@
81
90
<refsect1 role="returnvalues">
82
91
&reftitle.returnvalues;
83
92
<para>
84
-
The width of <type>string</type> <parameter>str</parameter>.
93
+
The width of <type>string</type> <parameter>string</parameter>.
85
94
</para>
86
95
</refsect1>
87
96

97
+
<refsect1 role="changelog">
98
+
&reftitle.changelog;
99
+
<informaltable>
100
+
<tgroup cols="2">
101
+
<thead>
102
+
<row>
103
+
<entry>&Version;</entry>
104
+
<entry>&Description;</entry>
105
+
</row>
106
+
</thead>
107
+
<tbody>
108
+
&mbstring.changelog.encoding-nullable;
109
+
</tbody>
110
+
</tgroup>
111
+
</informaltable>
112
+
</refsect1>
113
+

114
+
<refsect1 role="examples">
115
+
&reftitle.examples;
116
+
<example xml:id="mb-strwidth.example.basic">
117
+
<title><function>mb_strwidth</function> example</title>
118
+
<programlisting role="php">
119
+
<![CDATA[
120
+
<?php
121
+
var_dump(
122
+
mb_strwidth('a'), // LATIN SMALL LETTER A
123
+
mb_strwidth("\u{ff41}") // FULLWIDTH LATIN SMALL LETTER A
124
+
);
125
+
?>
126
+
]]>
127
+
</programlisting>
128
+
&example.outputs;
129
+
<screen>
130
+
<![CDATA[
131
+
int(1)
132
+
int(2)
133
+
]]>
134
+
</screen>
135
+
</example>
136
+
</refsect1>
137
+

88
138
<refsect1 role="seealso">
89
139
&reftitle.seealso;
90
140
<para>
...
...
@@ -96,7 +146,6 @@
96
146
</refsect1>
97
147

98
148
</refentry>
99
-

100
149
<!-- Keep this comment at the end of the file
101
150
Local variables:
102
151
mode: sgml
103
152