1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.24 $ -->
<reference id="ref.mbstring">
<title>Multi-Byte String Functions</title>
<titleabbrev>Multi-Byte String</titleabbrev>
<partintro>
<sect1 id="mb-intro">
<title>Introduction</title>
<para>
There are many languages in which all characters can be expressed
by single byte. Multi-byte character codes are used to express
many characters for many languages. <literal>mbstring</literal>
is developed to handle Japanese characters. However, many
<literal>mbstring</literal> functions are able to handle
character encoding other than Japanese.
</para>
<para>
A multi-byte character encoding represents single character with
consecutive bytes. Some character encoding has shift(escape)
sequences to start/end multi-byte character strings. Therefore, a
multi-byte character string may be destroyed when it is divided
and/or counted unless multi-byte character encoding safe method
is used. This module provides multi-byte character safe string
functions and other utility functions such as conversion
functions.
</para>
<para>
Since PHP is basically designed for ISO-8859-1, some multi-byte
character encoding does not work well with PHP. Therefore, it is
important to set <literal>mbstring.internal_encoding</literal> to
a character encoding that works with PHP.
</para>
<para>
PHP4 Character Encoding Requirements
</para>
<para>
<itemizedlist>
<listitem>
<simpara>
Per byte encoding
</simpara>
</listitem>
<listitem>
<simpara>
Single byte characters in range of <literal>00h-7fh</literal>
which is compatible with <literal>ASCII</literal>
</simpara>
</listitem>
<listitem>
<simpara>
Multi-byte characters without <literal>00h-7fh</literal>
</simpara>
</listitem>
</itemizedlist>
</para>
<para>
These are examples of internal character encoding that works with
PHP and does NOT work with PHP.
<informalexample>
<programlisting>
<![CDATA[
Character encodings work with PHP:
ISO-8859-*, EUC-JP, UTF-8
Character encodings do NOT work with PHP:
JIS, SJIS
]]>
</programlisting>
</informalexample>
</para>
<para>
Character encoding, that does not work with PHP, may be converted
with <literal>mbstring</literal>'s HTTP input/output conversion
feature/function.
</para>
<note>
<para>
SJIS should not be used for internal encoding unless the reader
is familiar with parser/compiler, character encoding and
character encoding issues.
</para>
</note>
<note>
<para>
If you use database with PHP, it is recommended that you use the
same character encoding for both database and <literal>internal
encoding</literal> for ease of use and better performance.
</para>
<para>
If you are using PostgreSQL, it supports character
encoding that is different from backend character encoding. See
the PostgreSQL manual for details.
</para>
</note>
<sect2 id="mb-enable">
<title>How to Enable mbstring</title>
<para>
<literal>mbstring</literal> is an extended module. You must
enable module with <literal>configure</literal> script. Refer
to the <link linkend="installation">Install</link> section for
details.
</para>
<simpara>
The following configure options are related to
<literal>mbstring</literal> module.
</simpara>
<para>
<itemizedlist>
<listitem>
<para>
<option role="configure">--enable-mbstring</option> : Enable
<literal>mbstring</literal> functions. This option is
required to use <literal>mbstring</literal> functions.
</para>
</listitem>
<listitem>
<para>
<option role="configure">--enable-mbstr-enc-trans</option> :
Enable HTTP input character encoding conversion using
<literal>mbstring</literal> conversion engine. If this
feature is enabled, HTTP input character encoding may be
converted to <literal>mbstring.internal_encoding</literal>
automatically.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
<sect2 id="mb-conv">
<title>HTTP Input and Output</title>
<para>
HTTP input/output character encoding conversion may convert
binary data also. Users are supposed to control character
encoding conversion if binary data is used for HTTP
input/output.
</para>
<para>
If <literal>enctype</literal> for HTML form is set to
<literal>multipart/form-data</literal>,
<literal>mbstring</literal> does not convert character encoding
in POST data. If it is the case, strings are needed to be
converted to internal character encoding.
</para>
<para>
<itemizedlist>
<listitem>
<simpara>
HTTP Input
</simpara>
<para> There is no way to control HTTP input character
conversion from PHP script. To disable HTTP input character
conversion, it has to be done in <literal>php.ini</literal>.
<example>
<title>
Disable HTTP input conversion in php.ini
</title>
<programlisting role="php">
<![CDATA[
;; Disable HTTP Input conversion
mbstring.http_input = pass
]]>
</programlisting>
</example>
</para>
<para>
When using PHP as an Apache module, it is possible to
override PHP ini setting per Virtual Host in
<literal>httpd.conf</literal> or per directory with
<literal>.htaccess</literal>. Refer to the <link
linkend="configuration">Configuration</link> section and
Apache Manual for details.
</para>
</listitem>
<listitem>
<simpara>
HTTP Output
</simpara>
<para>
There are several ways to enable output character encoding
conversion. One is using <literal>php.ini</literal>, another
is using <function>ob_start</function> with
<function>mb_output_handler</function> as
<literal>ob_start</literal> callback function.
</para>
<note>
<para>
For PHP3-i18n users, <literal>mbstring</literal>'s output
conversion differs from PHP3-i18n. Character encoding is
converted using output buffer.
</para>
</note>
</listitem>
</itemizedlist>
</para>
<para>
<example>
<title><literal>php.ini</literal> setting example</title>
<programlisting>
<![CDATA[
;; Enable output character encoding conversion for all PHP pages
;; Enable Output Buffering
output_buffering = On
;; Set mb_output_handler to enable output conversion
output_handler = mb_output_handler
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Script example</title>
<programlisting role="php">
<![CDATA[
<?php
// Enable output character encoding conversion only for this page
// Set HTTP output character encoding to SJIS
mb_http_output('SJIS');
// Start buffering and specify "mb_output_handler" as
// callback function
ob_start('mb_output_handler');
?>
]]>
</programlisting>
</example>
</para>
</sect2>
<sect2 id="mb-code">
<title>Supported Character Encoding</title>
<simpara>
Currently, the following character encoding is supported by
<literal>mbstring</literal> module. Caracter encoding may
be specified for <literal>mbstring</literal> functions'
<literal>encoding</literal> parameter. </simpara>
<para>
The following character encoding is supported in this PHP
extension :
</para>
<para>
<literal>UCS-4</literal>, <literal>UCS-4BE</literal>,
<literal>UCS-4LE</literal>, <literal>UCS-2</literal>,
<literal>UCS-2BE</literal>, <literal>UCS-2LE</literal>,
<literal>UTF-32</literal>, <literal>UTF-32BE</literal>,
<literal>UTF-32LE</literal>, <literal>UCS-2LE</literal>,
<literal>UTF-16</literal>, <literal>UTF-16BE</literal>,
<literal>UTF-16LE</literal>, <literal>UTF-8</literal>,
<literal>UTF-7</literal>, <literal>ASCII</literal>,
<literal>EUC-JP</literal>, <literal>SJIS</literal>,
<literal>eucJP-win</literal>, <literal>SJIS-win</literal>,
<literal>ISO-2022-JP</literal>, <literal>JIS</literal>,
<literal>ISO-8859-1</literal>, <literal>ISO-8859-2</literal>,
<literal>ISO-8859-3</literal>, <literal>ISO-8859-4</literal>,
<literal>ISO-8859-5</literal>, <literal>ISO-8859-6</literal>,
<literal>ISO-8859-7</literal>, <literal>ISO-8859-8</literal>,
<literal>ISO-8859-9</literal>, <literal>ISO-8859-10</literal>,
<literal>ISO-8859-13</literal>, <literal>ISO-8859-14</literal>,
<literal>ISO-8859-15</literal>, <literal>byte2be</literal>,
<literal>byte2le</literal>, <literal>byte4be</literal>,
<literal>byte4le</literal>, <literal>BASE64</literal>,
<literal>7bit</literal>, <literal>8bit</literal> and
<literal>UTF7-IMAP</literal>.
</para>
<para>
<literal>php.ini</literal> entry, which accepts encoding name,
accepts "<literal>auto</literal>" and
"<literal>pass</literal>" also.
<literal>mbstring</literal> functions, which accepts encoding
name, and accepts "<literal>auto</literal>".
</para>
<para>
If "<literal>pass</literal>" is set, no character
encoding conversion is performed.
</para>
<para>
If "<literal>auto</literal>" is set, it is expanded to
"<literal>ASCII,JIS,UTF-8,EUC-JP,SJIS</literal>".
</para>
<para>
See also <function>mb_detect_order</function>
</para>
<note>
<para>
"Supported character encoding" does not mean that it
works as internal character code.
</para>
</note>
</sect2>
<sect2 id="mb-ini">
<title>php.ini settings</title>
<para>
<itemizedlist>
<listitem>
<simpara>
<literal>mbstring.internal_encoding</literal> defines default
internal character encoding.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>mbstring.http_input</literal> defines default HTTP
input character encoding.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>mbstring.http_output</literal> defines default HTTP
output character encoding.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>mbstring.detect_order</literal> defines default
character code detection order. See also
<function>mb_detect_order</function>.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>mbstring.substitute_character</literal> defines
character to substitute for invalid character encoding.
</simpara>
</listitem>
</itemizedlist>
</para>
<para>
Web Browsers are supposed to use the same character encoding
when submitting form. However, browsers may not use the same
character encoding. See <function>mb_http_input</function> to
detect character encoding used by browsers.
</para>
<para>
If <literal>enctype</literal> is set to
<literal>multipart/form-data</literal> in HTML forms,
<literal>mbstring</literal> does not convert character encoding
in POST data. The user must convert them in the script, if
conversion is needed.
</para>
<para>
Although, browsers are smart enough to detect character encoding
in HTML. <literal>charset</literal> is better to be set in HTTP
header. Change <literal>default_charset</literal> according to
character encoding.
</para>
<para>
<example>
<title><literal>php.ini</literal> setting example</title>
<programlisting>
<![CDATA[
;; Set default internal encoding
;; Note: Make sure to use character encoding works with PHP
mbstring.internal_encoding = UTF-8 ; Set internal encoding to UTF-8
;; Set default HTTP input character encoding
;; Note: Script cannot change http_input setting.
mbstring.http_input = pass ; No conversion.
mbstring.http_input = auto ; Set HTTP input to auto
; "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS"
mbstring.http_input = SJIS ; Set HTTP2 input to SJIS
mbstring.http_input = UTF-8,SJIS,EUC-JP ; Specify order
;; Set default HTTP output character encoding
mbstring.http_output = pass ; No conversion
mbstring.http_output = UTF-8 ; Set HTTP output encoding to UTF-8
;; Set default character encoding detection order
mbstring.detect_order = auto ; Set detect order to auto
mbstring.detect_order = ASCII,JIS,UTF-8,SJIS,EUC-JP ; Specify order
;; Set default substitute character
mbstring.substitute_character = 12307 ; Specify Unicode value
mbstring.substitute_character = none ; Do not print character
mbstring.substitute_character = long ; Long Example: U+3000,JIS+7E7E
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title><literal>php.ini</literal> setting for <literal>EUC-JP</literal> users</title>
<programlisting>
<![CDATA[
;; Disable Output Buffering
output_buffering = Off
;; Set HTTP header charset
default_charset = EUC-JP
;; Set HTTP input encoding conversion to auto
mbstring.http_input = auto
;; Convert HTTP output to EUC-JP
mbstring.http_output = EUC-JP
;; Set internal encoding to EUC-JP
mbstring.internal_encoding = EUC-JP
;; Do not print invalid characters
mbstring.substitute_character = none
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title><literal>php.ini</literal> setting for <literal>SJIS</literal> users</title>
<programlisting>
<![CDATA[
;; Enable Output Buffering
output_buffering = On
;; Set mb_output_handler to enable output conversion
output_handler = mb_output_handler
;; Set HTTP header charset
default_charset = Shift_JIS
;; Set http input encoding conversion to auto
mbstring.http_input = auto
;; Convert to SJIS
mbstring.http_output = SJIS
;; Set internal encoding to EUC-JP
mbstring.internal_encoding = EUC-JP
;; Do not print invalid characters
mbstring.substitute_character = none
]]>
</programlisting>
</example>
</para>
</sect2>
<sect2 id="mb-overload">
<title>
Overload of PHP string functions by mbstring functions with
multibyte support
</title>
<para>
Because almost PHP application written for language using
single-byte character encoding, there are some difficulties for
multibyte string handling including japanese. Almost PHP string
functions such as <function>substr</function> do not support
multibyte string.
</para>
<para>
Multibyte extension (mbstring) has some PHP string functions
with multibyte support (ex. <function>substr</function> supports
<function>mb_substr</function>).
</para>
<para>
Multibyte extension (mbstring) also supports 'function
overloading' to add multibyte string functionality without
code modification. Using function overloading, some PHP string
functions will be oveloaded multibyte string functions.
For example, <function>mb_substr</function> is called
instead of <function>substr</function> if function overloading
is enabled. Function overload makes easy to port application
supporting only single-byte encoding for multibyte application.
</para>
<para>
<literal>mbstring.func_overload</literal> in php.ini should be
set some positive value to use function overloading.
The value should specify the category of overloading functions,
sbould be set 1 to enable mail function overloading. 2 to enable
string functions, 4 to regular expression functions. For
example, if is set for 7, mail, strings, regex functions should
be overloaded. The list of overloaded functions are shown in
below.
<table>
<title>Functions to be overloaded</title>
<tgroup cols="3">
<thead>
<row>
<entry>value of mbstring.func_overload</entry>
<entry>original function</entry>
<entry>overloaded function</entry>
</row>
</thead>
<tbody>
<row>
<entry>1</entry>
<entry><function>mail</function></entry>
<entry><function>mb_send_mail</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>strlen</function></entry>
<entry><function>mb_strlen</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>strpos</function></entry>
<entry><function>mb_strpos</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>strrpos</function></entry>
<entry><function>mb_strrpos</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>substr</function></entry>
<entry><function>mb_substr</function></entry>
</row>
<row>
<entry>4</entry>
<entry><function>ereg</function></entry>
<entry><function>mb_ereg</function></entry>
</row>
<row>
<entry>4</entry>
<entry><function>eregi</function></entry>
<entry><function>mb_eregi</function></entry>
</row>
<row>
<entry>4</entry>
<entry><function>ereg_replace</function></entry>
<entry><function>mb_ereg_replace</function></entry>
</row>
<row>
<entry>4</entry>
<entry><function>eregi_replace</function></entry>
<entry><function>mb_eregi_replace</function></entry>
</row>
<row>
<entry>4</entry>
<entry><function>split</function></entry>
<entry><function>mb_split</function></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</sect2>
<sect2 id="mb-ja-basic">
<title>Basics for Japanese multi-byte character</title>
<para>
Most Japanese characters need more than 1 byte per character. In
addition, several character encoding schemas are used under a
Japanese environment. There are EUC-JP, Shift_JIS(SJIS) and
ISO-2022-JP(JIS) character encoding. As Unicode becomes popular,
UTF-8 is used also. To develop Web applications for a Japanese
environment, it is important to use the character set for the
task in hand, whether HTTP input/output, RDBMS and E-mail.
</para>
<para>
<itemizedlist>
<listitem>
<simpara>Storage for a character can be up to six
bytes</simpara>
</listitem>
<listitem>
<simpara>
A multi-byte character is usually twice of the width compared
to single-byte characters. Wider characters are called
"zen-kaku" - meaning full width, narrower characters are
called "han-kaku" - meaning half width. "zen-kaku" characters
are usually fixed width.
</simpara>
</listitem>
<listitem>
<simpara>
Some character encoding defines shift(escape) sequence for
entering/exiting multi-byte character strings.
</simpara>
</listitem>
<listitem>
<simpara>
ISO-2022-JP must be used for SMTP/NNTP.
</simpara>
</listitem>
<listitem>
<para>
"i-mode" web site is supposed to use SJIS.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
<sect2 id="mb-ref">
<title>References</title>
<para>
Multi-byte character encoding and its related issues are very
complex. It is impossible to cover in sufficient detail
here. Please refer to the following URLs and other resources for
further readings.
<itemizedlist>
<listitem>
<para>
Unicode/UTF/UCS/etc
</para>
<para>
<literal>http://www.unicode.org/</literal>
</para>
</listitem>
<listitem>
<para>
Japanese/Korean/Chinese character
information
</para>
<para>
<literal>
ftp://ftp.ora.com/pub/examples/nutshell/ujip/doc/cjk.inf
</literal>
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
</sect1>
</partintro>
<refentry id="function.mb-language">
<refnamediv>
<refname>mb_language</refname>
<refpurpose>
Set/Get current language
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_language</methodname>
<methodparam choice="opt"><type>string</type><parameter>language</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_language</function> sets language. If
<parameter>language</parameter> is omitted, it returns current
language as string.
</para>
<para>
<parameter>language</parameter> setting is used for encoding
e-mail messages. Valid languages are "Japanese",
"ja","English","en" and "uni"
(UTF-8). <function>mb_send_mail</function> uses this setting to
encode e-mail.
</para>
<para> Language and its setting is ISO-2022-JP/Base64 for
Japanese, UTF-8/Base64 for uni, ISO-8859-1/quoted printable for
English.
</para>
<para>
Return Value: If <parameter>language</parameter> is set and
<parameter>language</parameter> is valid, it returns
&true;. Otherwise, it returns &false;. When
<parameter>language</parameter> is omitted, it returns language
name as string. If no language is set previously, it returns
&false;.
</para>
<para>
See also <function>mb_send_mail</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-parse-str">
<refnamediv>
<refname>mb_parse_str</refname>
<refpurpose>
Parse GET/POST/COOKIE data and set global variable
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>mb_parse_str</methodname>
<methodparam><type>string</type><parameter>encoded_string</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_parse_str</function> parses GET/POST/COOKIE data and
sets global variables. Since PHP does not provide raw POST/COOKIE
data, it can only used for GET data for now. It preses URL
encoded data, detects encoding, converts coding to internal
encoding and set values to <parameter>result</parameter> array or
global variables.
</para>
<para>
<parameter>encoded_string</parameter>: URL encoded data.
</para>
<para>
<parameter>result</parameter>: Array contains decoded and
character encoding converted values.
</para>
<para>
Return Value: It returns &true; for success or &false; for failure.
</para>
<para>
See also <function>mb_detect_order</function>,
<function>mb_internal_encoding</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-internal-encoding">
<refnamediv>
<refname>mb_internal_encoding</refname>
<refpurpose>
Set/Get internal character encoding
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_internal_encoding</methodname>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_internal_encoding</function> sets internal character
encoding to <parameter>encoding</parameter> If parameter is
omitted, it returns current internal encoding.
</para>
<para>
<parameter>encoding</parameter> is used for HTTP input character
encoding conversion, HTTP output character encoding conversion
and default character encoding for string functions defined by
mbstring module.
</para>
<para>
<parameter>encoding</parameter>: Character encoding name
</para>
<para>
Return Value: If <parameter>encoding</parameter> is
set,<function>mb_internal_encoding</function> returns
&true; for success, otherwise returns
&false;. If <parameter>encoding</parameter> is
omitted, it returns current character encoding name.
</para>
<para>
<example>
<title><function>mb_internal_encoding</function> example</title>
<programlisting role="php">
<![CDATA[
/* Set internal character encoding to UTF-8 */
mb_internal_encoding("UTF-8");
/* Display current internal character encoding */
echo mb_internal_encoding();
]]>
</programlisting>
</example>
</para>
<para>
See also <function>mb_http_input</function>,
<function>mb_http_output</function>,
<function>mb_detect_order</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-http-input">
<refnamediv>
<refname>mb_http_input</refname>
<refpurpose>Detect HTTP input character encoding</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_http_input</methodname>
<methodparam choice="opt"><type>string</type><parameter>type</parameter></methodparam>
</methodsynopsis>
<simpara>
<function>mb_http_input</function> returns result of HTTP input
character encoding detection.
</simpara>
<para>
<parameter>type</parameter>: Input string specifies input
type. "G" for GET, "P" for POST,
"C" for COOKIE. If type is omitted, it returns last
input type processed.
</para>
<para>
Return Value: Character encoding name.
If <function>mb_http_input</function> does not process specified
HTTP input, it returns &false;.
</para>
<para>
See also <function>mb_internal_encoding</function>,
<function>mb_http_output</function>,
<function>mb_detect_order</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-http-output">
<refnamediv>
<refname>mb_http_output</refname>
<refpurpose>Set/Get HTTP output character encoding</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_http_output</methodname>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
If <parameter>encoding</parameter> is set,
<function>mb_http_output</function> sets HTTP output character
encoding to <parameter>encoding</parameter>. Output after this
function is converted to <parameter>encoding</parameter>.
<function>mb_http_output</function> returns
&true; for success and &false;
for failure.
</para>
<para>
If <parameter>encoding</parameter> is omitted,
<function>mb_http_output</function> returns current HTTP output
character encoding.
</para>
<para>
See also <function>mb_internal_encoding</function>,
<function>mb_http_input</function>,
<function>mb_detect_order</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-detect-order">
<refnamediv>
<refname>mb_detect_order</refname>
<refpurpose>
Set/Get character encoding detection order
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>mb_detect_order</methodname>
<methodparam choice="opt"><type>mixed</type><parameter>encoding-list</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_detect_order</function> sets automatic character
encoding detection order to <parameter>encoding-list</parameter>.
It returns &true; for success,
&false; for failure.
</para>
<para>
<parameter>encoding-list</parameter> is array or comma separated
list of character encoding. ("auto" is expanded to
"ASCII, JIS, UTF-8, EUC-JP, SJIS")
</para>
<para>
If <parameter>encoding-list</parameter> is omitted, it returns
current character encoding detection order as array.
</para>
<para>
This setting affects <function>mb_detect_encoding</function> and
<function>mb_send_mail</function>.
</para>
<note>
<para>
<literal>mbstring</literal> currently implements following
encoding detection filters. If there is a invalid byte sequence
for following encoding, encoding detection will fail.
</para>
<simpara>
<literal>UTF-8</literal>, <literal>UTF-7</literal>,
<literal>ASCII</literal>,
<literal>EUC-JP</literal>,<literal>SJIS</literal>,
<literal>eucJP-win</literal>, <literal>SJIS-win</literal>,
<literal>JIS</literal>, <literal>ISO-2022-JP</literal>
</simpara>
<para>
For <literal>ISO-8859-*</literal>, <literal>mbstring</literal>
always detects as <literal>ISO-8859-*</literal>.
</para>
<para>
For <literal>UTF-16</literal>, <literal>UTF-32</literal>,
<literal>UCS2</literal> and <literal>UCS4</literal>, encoding
detection will fail always.
</para>
<para>
<example>
<title>Useless detect order example</title>
<programlisting>
<![CDATA[
; Always detect as ISO-8859-1
detect_order = ISO-8859-1, UTF-8
; Always detect as UTF-8, since ASCII/UTF-7 values are
; valid for UTF-8
detect_order = UTF-8, ASCII, UTF-7
]]>
</programlisting>
</example>
</para>
</note>
<para>
<example>
<title><function>mb_detect_order</function> examples</title>
<programlisting role="php">
<![CDATA[
/* Set detection order by enumerated list */
mb_detect_order("eucjp-win,sjis-win,UTF-8");
/* Set detection order by array */
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
mb_detect_order($ary);
/* Display current detection order */
echo implode(", ", mb_detect_order());
]]>
</programlisting>
</example>
</para>
<para>
See also <function>mb_internal_encoding</function>,
<function>mb_http_input</function>,
<function>mb_http_output</function>
<function>mb_send_mail</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-substitute-character">
<refnamediv>
<refname>mb_substitute_character</refname>
<refpurpose>Set/Get substitution character</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>mixed</type><methodname>mb_substitute_character</methodname>
<methodparam choice="opt"><type>mixed</type><parameter>substrchar</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_substitute_character</function> specifies
substitution character when input character encoding is invalid
or character code is not exist in output character
encoding. Invalid characters may be substituted &null;(no output),
string or integer value (Unicode character code value).
</para>
<para>
This setting affects <function>mb_detect_encoding</function>
and <function>mb_send_mail</function>.
</para>
<para>
<parameter>substchar</parameter> : Specify Unicode value as
integer or specify as string as follows
<itemizedlist>
<listitem>
<simpara>
"none" : no output
</simpara>
</listitem>
<listitem>
<simpara>
"long" : Output character code value (Example:
U+3000,JIS+7E7E)
</simpara>
</listitem>
</itemizedlist>
</para>
<para>
Return Value: If <parameter>substchar</parameter> is set, it
returns &true; for success, otherwise returns
&false;. If <parameter>substchar</parameter> is
not set, it returns Unicode value or
"<literal>none</literal>"/"<literal>long</literal>".
</para>
<para>
<example>
<title><function>mb_substitute_character</function> example</title>
<programlisting role="php">
<![CDATA[
/* Set with Unicode U+3013 (GETA MARK) */
mb_substitute_character(0x3013);
/* Set hex format */
mb_substitute_character("long");
/* Display current setting */
echo mb_substitute_character();
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.mb-output-handler">
<refnamediv>
<refname>mb_output_handler</refname>
<refpurpose>
Callback function converts character encoding in output buffer
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_output_handler</methodname>
<methodparam><type>string</type><parameter>contents</parameter></methodparam>
<methodparam><type>int</type><parameter>status</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_output_handler</function> is
<function>ob_start</function> callback
function. <function>mb_output_handler</function> converts
characters in output buffer from internal character encoding to
HTTP output character encoding.
</para>
<para>
4.1.0 or later version, this hanlder adds charset HTTP header
when following conditions are met:
</para>
<para>
<itemizedlist>
<listitem>
<simpara>Does not set <literal>Content-Type</literal> by
header()</simpara>
</listitem>
<listitem>
<simpara>Default MIME type begins with
<literal>text/</literal></simpara>
</listitem>
<listitem>
<simpara><literal>http_output</literal> setting is other than
pass</simpara>
</listitem>
</itemizedlist>
</para>
<para>
<parameter>contents</parameter> : Output buffer contents
</para>
<para>
<parameter>status</parameter> : Output buffer status
</para>
<para>
Return Value: String converted
</para>
<para>
<example>
<title><function>mb_output_handler</function> example</title>
<programlisting role="php">
<![CDATA[
mb_http_output("UTF-8");
ob_start("mb_output_handler");
]]>
</programlisting>
</example>
</para>
<note>
<para>
If you want to output some binary data such as image from PHP
script, you must set output encoding to "pass" using
<function>mb_http_output</function>.
</para>
</note>
<para>
See also <function>ob_start</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-preferred-mime-name">
<refnamediv>
<refname>mb_preferred_mime_name</refname>
<refpurpose>Get MIME charset string</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_preferred_mime_name</methodname>
<methodparam><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_preferred_mime_name</function> returns MIME
<literal>charset</literal> string for character encoding
<parameter>encoding</parameter>. It returns
<literal>charset</literal> string.
</para>
<para>
<example>
<title><function>mb_preferred_mime_string</function> example</title>
<programlisting role="php">
<![CDATA[
$outputenc = "sjis-win";
mb_http_output($outputenc);
ob_start("mb_output_handler");
header("Content-Type: text/html; charset=" . mb_preferred_mime_name($outputenc));
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.mb-strlen">
<refnamediv>
<refname>mb_strlen</refname>
<refpurpose>Get string length</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_strlen</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_strlen</function> returns number of characters in
string <parameter>str</parameter> having character encoding
<parameter>encoding</parameter>. A multi-byte character is
counted as 1.
</para>
<para>
<parameter>encoding</parameter> is character encoding for
<parameter>str</parameter>. If <parameter>encoding</parameter> is
omitted, internal character encoding is used.
</para>
<para>
See also <function>mb_internal_encoding</function>,
<function>strlen</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-strpos">
<refnamediv>
<refname>mb_strpos</refname>
<refpurpose>
Find position of first occurrence of string in a string
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>mb_strpos</methodname>
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
<methodparam><type>string</type><parameter>needle</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>offset</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_strpos</function> returns the numeric position of
the first occurrence of <parameter>needle</parameter> in the
<parameter>haystack</parameter> string. If
<parameter>needle</parameter> is not found, it returns &false;.
</para>
<para>
<function>mb_strpos</function> performs multi-byte safe
<function>strpos</function> operation based on number of
characters. <parameter>needle</parameter> position is counted
from the beginning of the <parameter>haystack</parameter>. First
character's position is 0. Second character position is 1, and so
on.
</para>
<para>
If <parameter>encoding</parameter> is omitted, internal
character encoding is used. <function>mb_strrpos</function>
accepts <literal>string</literal> for
<parameter>needle</parameter> where <function>strrpos</function>
accepts only character.
</para>
<para>
<parameter>offset</parameter> is search offset. If it is not
specified, 0 is used.
</para>
<para>
<parameter>encoding</parameter> is character encoding name. If it
is omitted, internal character encoding is used.
</para>
<para>
See also <function>mb_strpos</function>,
<function>mb_internal_encoding</function>,
<function>strpos</function>
</para>
</refsect1>
</refentry>
<refentry id="function.mb-strrpos">
<refnamediv>
<refname>mb_strrpos</refname>
<refpurpose>
Find position of last occurrence of a string in a string
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>mb_strrpos</methodname>
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
<methodparam><type>string</type><parameter>needle</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_strrpos</function> returns the numeric position of
the last occurrence of <parameter>needle</parameter> in the
<parameter>haystack</parameter> string. If
<parameter>needle</parameter> is not found, it returns &false;.
</para>
<para>
<function>mb_strrpos</function> performs multi-byte safe
<function>strrpos</function> operation based on
number of characters. <parameter>needle</parameter> position is
counted from the beginning of
<parameter>haystack</parameter>. First character's position is
0. Second character position is 1.
</para>
<para>
If <parameter>encoding</parameter> is omitted, internal encoding
is assumed. <function>mb_strrpos</function> accepts
<literal>string</literal> for <parameter>needle</parameter> where
<function>strrpos</function> accepts only character.
</para>
<para>
<parameter>encoding</parameter> is character encoding. If it is
not specified, internal character encoding is used.
</para>
<para>
See also <function>mb_strpos</function>,
<function>mb_internal_encoding</function>,
<function>strrpos</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-substr">
<refnamediv>
<refname>mb_substr</refname>
<refpurpose>Get part of string</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_substr</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>int</type><parameter>start</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_substr</function> returns the portion of
<parameter>str</parameter> specified by the
<parameter>start</parameter> and
<parameter>length</parameter> parameters.
</para>
<para>
<function>mb_substr</function> performs multi-byte safe
<function>substr</function> operation based on
number of characters. Position is
counted from the beginning of
<parameter>str</parameter>. First character's position is
0. Second character position is 1, and so on.
</para>
<para>
If <parameter>encoding</parameter> is omitted, internal encoding
is assumed.
</para>
<para>
<parameter>encoding</parameter> is character encoding. If it is
omitted, internal character encoding is used.
</para>
<para>
See also <function>mb_strcut</function>,
<function>mb_internal_encoding</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-strcut">
<refnamediv>
<refname>mb_strcut</refname>
<refpurpose>Get part of string</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_strcut</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>int</type><parameter>start</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_strcut</function> returns the portion of
<parameter>str</parameter> specified by the
<parameter>start</parameter> and
<parameter>length</parameter> parameters.
</para>
<para>
<function>mb_strcut</function> performs equivalent operation as
<function>mb_substr</function> with different method. If
<parameter>start</parameter> position is multi-byte character's
second byte or larger, it starts from first byte of multi-byte
character.
</para>
<para>
It subtracts string from <parameter>str</parameter> that is
shorter than <parameter>length</parameter> AND character that is
not part of multi-byte string or not being middle of shift
sequence.
</para>
<para>
<parameter>encoding</parameter> is character encoding. If it is
not set, internal character encoding is used.
</para>
<para>
See also <function>mb_substr</function>,
<function>mb_internal_encoding</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-strwidth">
<refnamediv>
<refname>mb_strwidth</refname>
<refpurpose>Return width of string</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>mb_strwidth</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_strwidth</function> returns width of string
<parameter>str</parameter>.
</para>
<para>
Multi-byte character usually twice of width compare to single
byte character.
</para>
<para>
<informalexample>
<programlisting>
<![CDATA[
Character width
U+0000 - U+0019 0
U+0020 - U+1FFF 1
U+2000 - U+FF60 2
U+FF61 - U+FF9F 1
U+FFA0 - 2
]]>
</programlisting>
</informalexample>
</para>
<para>
<parameter>encoding</parameter> is character encoding. If it is
omitted, internal encoding is used.
</para>
<para>
See also: <function>mb_strimwidth</function>,
<function>mb_internal_encoding</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-strimwidth">
<refnamediv>
<refname>mb_strimwidth</refname>
<refpurpose>Get truncated string with specified width</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_strimwidth</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>int</type><parameter>start</parameter></methodparam>
<methodparam><type>int</type><parameter>width</parameter></methodparam>
<methodparam><type>string</type><parameter>trimmarker</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_strimwidth</function> truncates string
<parameter>str</parameter> to specified
<parameter>width</parameter>. It returns truncated string.
</para>
<para>
If <parameter>trimmarker</parameter> is set,
<parameter>trimmarker</parameter> is appended to return value.
</para>
<para>
<parameter>start</parameter> is start position offset. Number of
characters from the beginning of string. (First character is 0)
</para>
<para>
<parameter>trimmarker</parameter> is string that is added to the
end of string when string is truncated.
</para>
<para>
<parameter>encoding</parameter> is character encoding. If it is
omitted, internal encoding is used.
</para>
<para>
<example>
<title><function>mb_strimwidth</function> example</title>
<programlisting role="php">
<![CDATA[
$str = mb_strimwidth($str, 0, 40, "..>");
]]>
</programlisting>
</example>
</para>
<para>
See also: <function>mb_strwidth</function>,
<function>mb_internal_encoding</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-convert-encoding">
<refnamediv>
<refname>mb_convert_encoding</refname>
<refpurpose>Convert character encoding</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_convert_encoding</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>string</type><parameter>to-encoding</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>from-encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_convert_encoding</function> converts
character encoding of string <parameter>str</parameter> from
<parameter>from-encoding</parameter> to
<parameter>to-encoding</parameter>.
</para>
<para>
<parameter>str</parameter> : String to be converted.
</para>
<para>
<parameter>from-encoding</parameter> is specified by character
code name before conversion. it can be array or string - comma
separated enumerated list.
</para>
<para>
<example>
<title><function>mb_convert_encoding</function> example</title>
<programlisting role="php">
<![CDATA[
/* Convert internal character encoding to SJIS */
$str = mb_convert_encoding($str, "SJIS");
/* Convert EUC-JP to UTF-7 */
$str = mb_convert_encoding($str, "UTF-7", "EUC-JP");
/* Auto detect encoding from JIS, eucjp-win, sjis-win, then convert str to UCS-2LE */
$str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win");
/* "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
$str = mb_convert_encoding($str, "EUC-JP", "auto");
]]>
</programlisting>
</example>
</para>
<para>
See also: <function>mb_detect_order</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-detect-encoding">
<refnamediv>
<refname>mb_detect_encoding</refname>
<refpurpose>Detect character encoding</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_detect_encoding</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>encoding-list</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_detect_encoding</function> detects character
encoding in string <parameter>str</parameter>. It returns
detected character encoding.
</para>
<para>
<parameter>encoding-list</parameter> is list of character
encoding. Encoding order may be specified by array or comma
separated list string.
</para>
<para>
If <parameter>encoding_list</parameter> is omitted,
detect_order is used.
</para>
<para>
<example>
<title><function>mb_detect_encoding</function> example</title>
<programlisting role="php">
<![CDATA[
/* Detect character encoding with current detect_order */
echo mb_detect_encoding($str);
/* "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
echo mb_detect_encoding($str, "auto");
/* Specify encoding_list character encoding by comma separated list */
echo mb_detect_encoding($str, "JIS, eucjp-win, sjis-win");
/* Use array to specify encoding_list */
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
echo mb_detect_encoding($str, $ary);
]]>
</programlisting>
</example>
</para>
<para>
See also: <function>mb_detect_order</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-convert-kana">
<refnamediv>
<refname>mb_convert_kana</refname>
<refpurpose>
Convert "kana" one from another ("zen-kaku" ,"han-kaku" and more)
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_convert_kana</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>string</type><parameter>option</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_convert_kana</function> performs "han-kaku" -
"zen-kaku" conversion for string <parameter>str</parameter>. It
returns converted string. This function is only useful for
Japanese.
</para>
<para>
<parameter>option</parameter> is conversion option. Default value
is <literal>"KV"</literal>.
</para>
<para>
<parameter>encoding</parameter> is character encoding. If it is
omitted, internal character encoding is used.
</para>
<para>
<informalexample>
<programlisting>
<![CDATA[
Applicable Conversion Options
option : Specify with conversion of following options. Default "KV"
"r" : Convert "zen-kaku" alphabets to "han-kaku"
"R" : Convert "han-kaku" alphabets to "zen-kaku"
"n" : Convert "zen-kaku" numbers to "han-kaku"
"N" : Convert "han-kaku" numbers to "zen-kaku"
"a" : Convert "zen-kaku" alphabets and numbers to "han-kaku"
"A" : Convert "zen-kaku" alphabets and numbers to "han-kaku"
(Characters included in "a", "A" options are
U+0021 - U+007E excluding U+0022, U+0027, U+005C, U+007E)
"s" : Convert "zen-kaku" space to "han-kaku" (U+3000 -> U+0020)
"S" : Convert "han-kaku" space to "zen-kaku" (U+0020 -> U+3000)
"k" : Convert "zen-kaku kata-kana" to "han-kaku kata-kana"
"K" : Convert "han-kaku kata-kana" to "zen-kaku kata-kana"
"h" : Convert "zen-kaku hira-gana" to "han-kaku kata-kana"
"H" : Convert "han-kaku kata-kana" to "zen-kaku hira-gana"
"c" : Convert "zen-kaku kata-kana" to "zen-kaku hira-gana"
"C" : Convert "zen-kaku hira-gana" to "zen-kaku kata-kana"
"V" : Collapse voiced sound notation and convert them into a character. Use with "K","H"
]]>
</programlisting>
</informalexample>
</para>
<para>
<example>
<title><function>mb_convert_kana</function> example</title>
<programlisting role="php">
<![CDATA[
/* Convert all "kana" to "zen-kaku" "kata-kana" */
$str = mb_convert_kana($str, "KVC");
/* Convert "han-kaku" "kata-kana" to "zen-kaku" "kata-kana"
and "zen-kaku" alpha-numeric to "han-kaku" */
$str = mb_convert_kana($str, "KVa");
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.mb-encode-mimeheader">
<refnamediv>
<refname>mb_encode_mimeheader</refname>
<refpurpose>Encode string for MIME header</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_encode_mimeheader</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>charset</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>transfer-encoding</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>linefeed</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_encode_mimeheader</function> converts string
<parameter>str</parameter> to encoded-word for header field.
It returns converted string in ASCII encoding.
</para>
<para>
<parameter>charset</parameter> is character encoding
name. Default is <literal>ISO-2022-JP</literal>.
</para>
<para>
<parameter>transfer-encoding</parameter> is transfer encoding. It
should be one of <literal>"B"</literal> (Base64) or
<literal>"Q"</literal> (Quoted-Printable). Default is
<literal>"B"</literal>.
</para>
<para>
<parameter>linefeed</parameter> is end of line marker. Default is
<literal>"\r\n"</literal> (CRLF).
</para>
<para>
<example>
<title><function>mb_convert_kana</function> example</title>
<programlisting role="php">
<![CDATA[
$name = ""; // kanji
$mbox = "kru";
$doma = "gtinn.mon";
$addr = mb_encode_mimeheader($name, "UTF-7", "Q") . " <" . $mbox . "@" . $doma . ">";
echo $addr;
]]>
</programlisting>
</example>
</para>
<para>
See also <function>mb_decode_mimeheader</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-decode-mimeheader">
<refnamediv>
<refname>mb_decode_mimeheader</refname>
<refpurpose>Decode string in MIME header field</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_decode_mimeheader</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_decode_mimeheader</function> decodes encoded-word
string <parameter>str</parameter> in MIME header.
</para>
<para>
It returns decoded string in internal character encoding.
</para>
<para>
See also <function>mb_encode_mimeheader</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-convert-variables">
<refnamediv>
<refname>mb_convert_variables</refname>
<refpurpose>Convert character code in variable(s)</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_convert_variables</methodname>
<methodparam><type>string</type><parameter>to-encoding</parameter></methodparam>
<methodparam><type>mixed</type><parameter>from-encoding</parameter></methodparam>
<methodparam><type>mixed</type><parameter>vars</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_convert_variables</function> convert
character encoding of variables <parameter>vars</parameter> in
encoding <parameter>from-encoding</parameter> to encoding
<parameter>to-encoding</parameter>. It returns character encoding
before conversion for success, &false; for failure.
</para>
<para>
<function>mb_convert_variables</function> join strings in Array
or Object to detect encoding, since encoding detection tends to
fail for short strings. Therefore, it is impossible to mix
encoding in single array or object.
</para>
<para>
It <parameter>from-encoding</parameter> is specified by
array or comma separated string, it tries to detect encoding from
<parameter>from-coding</parameter>. When
<parameter>encoding</parameter> is omitted,
<literal>detect_order</literal> is used.
</para>
<para>
<parameter>vars (3rd and larger)</parameter> is reference to
variable to be converted. String, Array and Object are accepted.
<function>mb_convert_variables</function> assumes all parameters
have the same encoding.
</para>
<para>
<example>
<title><function>mb_convert_variables</function> example</title>
<programlisting role="php">
<![CDATA[
/* Convert variables $post1, $post2 to internal encoding */
$interenc = mb_internal_encoding();
$inputenc = mb_convert_variables($interenc, "ASCII,UTF-8,SJIS-win", $post1, $post2);
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<refentry id="function.mb-encode-numericentity">
<refnamediv>
<refname>mb_encode_numericentity</refname>
<refpurpose>
Encode character to HTML numeric string reference
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_encode_numericentity</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>array</type><parameter>convmap</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_encode_numericentity</function> converts
specified character codes in string <parameter>str</parameter>
from HTML numeric character reference to character code. It
returns converted string.
</para>
<para>
<parameter>array</parameter> is array specifies code area to
convert.
</para>
<para>
<parameter>encoding</parameter> is character encoding.
</para>
<para>
<example>
<title><parameter>convmap</parameter> example</title>
<programlisting role="php">
<![CDATA[
$convmap = array (
int start_code1, int end_code1, int offset1, int mask1,
int start_code2, int end_code2, int offset2, int mask2,
........
int start_codeN, int end_codeN, int offsetN, int maskN );
// Specify Unicode value for start_codeN and end_codeN
// Add offsetN to value and take bit-wise 'AND' with maskN, then
// it converts value to numeric string reference.
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>
<function>mb_encode_numericentity</function> example
</title>
<programlisting role="php">
<![CDATA[
/* Convert Left side of ISO-8859-1 to HTML numeric character reference */
$convmap = array(0x80, 0xff, 0, 0xff);
$str = mb_encode_numericentity($str, $convmap, "ISO-8859-1");
/* Convert user defined SJIS-win code in block 95-104 to numeric
string reference */
$convmap = array(
0xe000, 0xe03e, 0x1040, 0xffff,
0xe03f, 0xe0bb, 0x1041, 0xffff,
0xe0bc, 0xe0fa, 0x1084, 0xffff,
0xe0fb, 0xe177, 0x1085, 0xffff,
0xe178, 0xe1b6, 0x10c8, 0xffff,
0xe1b7, 0xe233, 0x10c9, 0xffff,
0xe234, 0xe272, 0x110c, 0xffff,
0xe273, 0xe2ef, 0x110d, 0xffff,
0xe2f0, 0xe32e, 0x1150, 0xffff,
0xe32f, 0xe3ab, 0x1151, 0xffff );
$str = mb_encode_numericentity($str, $convmap, "sjis-win");
]]>
</programlisting>
</example>
</para>
<para>
See also: <function>mb_decode_numericentity</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-decode-numericentity">
<refnamediv>
<refname>mb_decode_numericentity</refname>
<refpurpose>
Decode HTML numeric string reference to character
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_decode_numericentity</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>array</type><parameter>convmap</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter></methodparam>
</methodsynopsis>
<para>
Convert numeric string reference of string
<parameter>str</parameter> in specified block to character. It
returns converted string.
</para>
<para>
<parameter>array</parameter> is array to specifies code area to
convert.
</para>
<para>
<parameter>encoding</parameter> is character encoding. If it is
omitted, internal character encoding is used.
</para>
<para>
<example>
<title><parameter>convmap</parameter> example</title>
<programlisting role="php">
<![CDATA[
$convmap = array (
int start_code1, int end_code1, int offset1, int mask1,
int start_code2, int end_code2, int offset2, int mask2,
........
int start_codeN, int end_codeN, int offsetN, int maskN );
// Specify Unicode value for start_codeN and end_codeN
// Add offsetN to value and take bit-wise 'AND' with maskN,
// then convert value to numeric string reference.
]]>
</programlisting>
</example>
</para>
<para>
See also: <function>mb_encode_numericentity</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-send-mail">
<refnamediv>
<refname>mb_send_mail</refname>
<refpurpose>
Send encoded mail.
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>boolean</type><methodname>mb_send_mail</methodname>
<methodparam><type>string</type><parameter>to</parameter></methodparam>
<methodparam><type>string</type><parameter>subject</parameter></methodparam>
<methodparam><type>string</type><parameter>message</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>additional_headers</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>additional_parameter</parameter></methodparam>
</methodsynopsis>
<para>
<function>mb_send_mail</function> sends email. Headers and
message are converted and encoded according to
<function>mb_language</function> setting.
<function>mb_send_mail</function> is wrapper
function of <function>mail</function>. See
<function>mail</function> for details.
</para>
<para>
<parameter>to</parameter> is mail addresses send to. Multiple
recipients can be specified by putting a comma between each
address in to. This parameter is not automatically encoded.
</para>
<para>
<parameter>subject</parameter> is subject of mail.
</para>
<para>
<parameter>message</parameter> is mail message.
</para>
<para>
<parameter>additional_headers</parameter> is inserted at
the end of the header. This is typically used to add extra
headers. Multiple extra headers are separated with a
newline ("\n").
</para>
<para>
<parameter>additional_parameter</parameter> is a MTA command line
parameter. It is useful when setting the correct Return-Path
header when using sendmail.
</para>
<para>
&return.success;
</para>
<para>
See also <function>mail</function>,
<function>mb_encode_mimeheader</function>, and
<function>mb_language</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-get-info">
<refnamediv>
<refname>mb_get_info</refname>
<refpurpose>Get internal settings of mbstring</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_get_info</methodname>
<methodparam choice="opt"><type>string</type><parameter>type</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_get_info</function> returns internal setting
parameter of mbstring.
</simpara>
<para>
If <parameter>type</parameter> isn't specified or is specified to
"all", an array having the elements "internal_encoding",
"http_output", "http_input", "func_overload" will be returned.
</para>
<para>
If <parameter>type</parameter> is specified for "http_output",
"http_input", "internal_encoding", "func_overload",
the specified setting parameter will be returned.
</para>
<para>
See also <function>mb_internal_encoding</function>,
<function>mb_http_output</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-regex-encoding">
<refnamediv>
<refname>mb_regex_encoding</refname>
<refpurpose>
Returns current encoding for multibyte regex as string
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_regex_encoding</methodname>
<methodparam choice="opt">
<type>string</type><parameter>encoding</parameter>
</methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_regex_encoding</function> returns the character
encoding used by multibyte regex functions.
</simpara>
<para>
If the optional parameter <parameter>encoding</parameter> is
specified, it is set to the character encoding for multibyte
regex. The default value is the internal character encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_internal_encoding</function>,
<function>mb_ereg</function>
</para>
</refsect1>
</refentry>
<refentry id="function.mb-ereg">
<refnamediv>
<refname>mb_ereg</refname>
<refpurpose>Regular expression match with multibyte support</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>mb_ereg</methodname>
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt">
<type>array</type><parameter>regs</parameter>
</methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg</function> executes the regular expression
match with multibyte support, and returns 1 if matches are found.
If the optional third parameter was specified, the function
returns the byte length of matched part, and therarray
<parameter>regs</parameter> will contain the substring of matched
string. The functions returns 1 if it matches with the empty
string. It no matche found or error happend, &false; will be
returned.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_eregi</function>
</para>
</refsect1>
</refentry>
<refentry id="function.mb-eregi">
<refnamediv>
<refname>mb_eregi</refname>
<refpurpose>
Regular expression match ignoring case with multibyte support
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>mb_eregi</methodname>
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt">
<type>array</type><parameter>regs</parameter>
</methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_eregi</function> executes the regular expression
match with multibyte support, and returns 1 if matches are found.
This function ignore case.
If the optional third parameter was specified, the function
returns the byte length of matched part, and therarray
<parameter>regs</parameter> will contain the substring of matched
string. The functions returns 1 if it matches with the empty
string. It no matche found or error happend, &false; will be
returned.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-ereg-replace">
<refnamediv>
<refname>mb_ereg_replace</refname>
<refpurpose>Replace regular expression with multibyte support</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_ereg_replace</methodname>
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
<methodparam><type>string</type><parameter>replacement</parameter></methodparam>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt">
<type>array</type><parameter>option</parameter>
</methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg_replace</function> scans
<parameter>string</parameter> for matches to
<parameter>pattern</parameter>, then replaces the matched text
with <parameter>replacement</parameter> and returns the result
string or &false; on error. Multibyte character can be used in
<parameter>pattern</parameter>.
</simpara>
<simpara>
Matching condition can be set by <parameter>option</parameter>
parameter. If <literal>i</literal> is specified for this
parameter, the case will be ignored. If <literal>x</literal> is
specified, white space will be ignored. If <literal>m</literal>
is specified, match will be executed in multiline mode and line
break will be included in '.'. If <literal>p</literal> is
specified, match will be executed in POSIX mode, line break
will be considered as normal character. If <literal>e</literal>
is specified, <parameter>replacement</parameter> string will be
evaluated as PHP expression.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_eregi_replace</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-eregi-replace">
<refnamediv>
<refname>mb_eregi_replace</refname>
<refpurpose>
Replace regular expression with multibyte support
ignoring case
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mb_eregi_replace</methodname>
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
<methodparam><type>string</type><parameter>replace</parameter></methodparam>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg_replace</function> scans
<parameter>string</parameter> for matches to
<parameter>pattern</parameter>, then replaces the matched text
with <parameter>replacement</parameter> and returns the result
string or &false; on error. Multibyte character can be used in
<parameter>pattern</parameter>. The case will be ignored.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg_replace</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-split">
<refnamediv>
<refname>mb_split</refname>
<refpurpose>Split multibyte string using regular expression</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>mb_split</methodname>
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt">
<type>int</type><parameter>limit</parameter>
</methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_split</function> split multibyte
<parameter>string</parameter> using regular expression
<parameter>pattern</parameter> and returns the result as an
array.
</simpara>
<simpara>
If optional parameter <parameter>limit</parameter> is specified,
it will be split in <parameter>limit</parameter> elements as
maximum.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-ereg-match">
<refnamediv>
<refname>mb_ereg_match</refname>
<refpurpose>
Regular expression match for multibyte string
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>mb_ereg_match</methodname>
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt">
<type>string</type><parameter>option</parameter>
</methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg_match</function> returns &true; if
<parameter>string</parameter> matches regular expression
<parameter>pattern</parameter>, &false; if not.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-ereg-search">
<refnamediv>
<refname>mb_ereg_search</refname>
<refpurpose>
Multibyte regular expression match for predefined multibyte string
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>mb_ereg_search</methodname>
<methodparam choice="opt">
<type>string</type><parameter>pattern</parameter>
</methodparam>
<methodparam choice="opt">
<type>string</type><parameter>option</parameter>
</methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg_search</function> returns &true; if the
multibyte string matches with the regular expression, &false; for
otherwise. The string for matching is set by
<function>mb_ereg_search_init</function>. If
<parameter>pattern</parameter> is not specified, the previous one
is used.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg_search_init</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-ereg-search-pos">
<refnamediv>
<refname>mb_ereg_search_pos</refname>
<refpurpose>
Return position and length of matched part of multibyte regular
expression for predefined multibyte string
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>mb_ereg_search_pos</methodname>
<methodparam choice="opt">
<type>string</type><parameter>pattern</parameter>
</methodparam>
<methodparam choice="opt">
<type>string</type><parameter>option</parameter>
</methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg_search_pos</function> returns an array including
position of matched part for multibyte regular expression.
The first element of the array will be the beggining of matched
part, the second element will be length (bytes) of matched part.
It returns &false; on error.
</simpara>
<para>
The string for match is specified by
<function>mb_ereg_search_init</function>. It it is not specified,
the previous one will be used.
</para>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg_search_init</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-ereg-search-regs">
<refnamediv>
<refname>mb_ereg_search_regs</refname>
<refpurpose>
Returns the matched part of multibyte regular expression
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>mb_ereg_search_regs</methodname>
<methodparam choice="opt">
<type>string</type><parameter>pattern</parameter>
</methodparam>
<methodparam choice="opt">
<type>string</type><parameter>option</parameter>
</methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg_search_regs</function> executes the multibyte
regular expression match, and if there are some matched part, it
returns an array including substring of matched part as first
element, the first grouped part with brackets as second element,
the second grouped part as third element, and so on. It returns
&false; on error.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg_search_init</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-ereg-search-init">
<refnamediv>
<refname>mb_ereg_search_init</refname>
<refpurpose>
Setup string and regular expression for multibyte regular
expression match
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>mb_ereg_search_init</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt">
<type>string</type><parameter>pattern</parameter>
</methodparam>
<methodparam choice="opt">
<type>string</type><parameter>option</parameter>
</methodparam>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg_search_init</function> sets
<parameter>string</parameter> and <parameter>pattern</parameter>
for multibyte regular expression. These values are used for
<function>mb_ereg_search</function>,
<function>mb_ereg_search_pos</function>,
<function>mb_ereg_search_regs</function>. It returns &true; for
success, &false; for error.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg_search_regs</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-ereg-search-getregs">
<refnamediv>
<refname>mb_ereg_search_getregs</refname>
<refpurpose>
Retrive the result from the last multibyte regular expression
match
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>mb_ereg_search_getregs</methodname>
<void/>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg_search_getregs</function> returns an array
including the sub-string of matched part by last
<function>mb_ereg_search</function>,
<function>mb_ereg_search_pos</function>,
<function>mb_ereg_search_regs</function>. If there are some
maches, the first element will have the matched sub-string, the
second element will have the first part grouped with brackets,
the third element will have the second part grouped with
brackets, and so on. It returns &false; on error;
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg_search_init</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-ereg-search-getpos">
<refnamediv>
<refname>mb_ereg_search_getpos</refname>
<refpurpose>
Returns start point for next regular expression match
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>mb_ereg_search_getpos</methodname>
<void/>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg_search_getpos</function> returns
the point to start regular expression match for
<function>mb_ereg_search</function>,
<function>mb_ereg_search_pos</function>,
<function>mb_ereg_search_regs</function>. The position is
represented by bytes from the head of string.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg_search_setpos</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mb-ereg-search-setpos">
<refnamediv>
<refname>mb_ereg_search_setpos</refname>
<refpurpose>
Set start point of next regular expression match
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>mb_ereg_search_setpos</methodname>
<void/>
</methodsynopsis>
&warn.experimental.func;
<simpara>
<function>mb_ereg_search_setpos</function> sets the starting
point of match for <function>mb_ereg_search</function>.
</simpara>
<para>
The internal encoding or the character encoding specified in
<function>mb_regex_encoding</function> will be used as character
encoding.
</para>
<note>
<para>
This function is supported in PHP 4.2.0 or higher.
</para>
</note>
<para>
See also: <function>mb_regex_encoding</function>,
<function>mb_ereg_search_init</function>.
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
|