summaryrefslogtreecommitdiff
path: root/src/HTML5/Parser/StringInputStream.php
diff options
context:
space:
mode:
authorMatt Butcher <[email protected]>2013-04-10 10:38:26 -0500
committerMatt Butcher <[email protected]>2013-04-10 10:38:26 -0500
commit04fde93f07af13fdf5ddf5d5d539467135221d2a (patch)
tree41b5dc2594b44ef832bacba740f71a1c771487b0 /src/HTML5/Parser/StringInputStream.php
parentb50dd3df9f5c4eb3dccf50b9f6434bacbbf8820a (diff)
Use UTF8Utils.
Diffstat (limited to 'src/HTML5/Parser/StringInputStream.php')
-rw-r--r--src/HTML5/Parser/StringInputStream.php30
1 files changed, 1 insertions, 29 deletions
diff --git a/src/HTML5/Parser/StringInputStream.php b/src/HTML5/Parser/StringInputStream.php
index 3d6b96e..4ceae44 100644
--- a/src/HTML5/Parser/StringInputStream.php
+++ b/src/HTML5/Parser/StringInputStream.php
@@ -258,35 +258,7 @@ class StringInputStream implements InputStream {
$findLengthOf = substr($this->data, 0, $this->char);
}
- return self::countChars($findLengthOf);
- }
-
- /**
- * Count the number of characters in a string.
- *
- * UTF-8 aware. This will try (in order) iconv,
- * MB, libxml, and finally a custom counter.
- *
- * @todo Move this to a general utility class.
- */
- public static function countChars($string) {
- // Get the length for the string we need.
- if(function_exists('iconv_strlen')) {
- return iconv_strlen($string, 'utf-8');
- }
- elseif(function_exists('mb_strlen')) {
- return mb_strlen($string, 'utf-8');
- }
- elseif(function_exists('utf8_decod')) {
- // MPB: Will this work? Won't certain decodes lead to two chars
- // extrapolated out of 2-byte chars?
- return strlen(utf8_decode($string));
- }
- $count = count_chars($string);
- // 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)
- // 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)
- return array_sum(array_slice($count, 0, 0x80)) +
- array_sum(array_slice($count, 0xC2, 0x33));
+ return UTF8Utils::countChars($findLengthOf);
}
/**