Changeset View
Changeset View
Standalone View
Standalone View
src/utils/utf8.php
| Show First 20 Lines • Show All 420 Lines • ▼ Show 20 Lines | |||||
| * Split a UTF-8 string into an array of characters. Combining characters are | * Split a UTF-8 string into an array of characters. Combining characters are | ||||
| * also split. | * also split. | ||||
| * | * | ||||
| * @param string A valid utf-8 string. | * @param string A valid utf-8 string. | ||||
| * @param int|null Stop processing after examining this many bytes. | * @param int|null Stop processing after examining this many bytes. | ||||
| * @return list A list of characters in the string. | * @return list A list of characters in the string. | ||||
| */ | */ | ||||
| function phutil_utf8v($string, $byte_limit = null) { | function phutil_utf8v($string, $byte_limit = null) { | ||||
| $string = phutil_string_cast($string); | |||||
| $res = array(); | $res = array(); | ||||
| $len = strlen($string); | $len = strlen($string); | ||||
| $ii = 0; | $ii = 0; | ||||
| while ($ii < $len) { | while ($ii < $len) { | ||||
| $byte = $string[$ii]; | $byte = $string[$ii]; | ||||
| if ($byte <= "\x7F") { | if ($byte <= "\x7F") { | ||||
| $res[] = $byte; | $res[] = $byte; | ||||
| ▲ Show 20 Lines • Show All 546 Lines • Show Last 20 Lines | |||||