function _fuzzysearch_char_count in Fuzzy Search 6
Same name and namespace in other branches
- 7 fuzzysearch.module \_fuzzysearch_char_count()
1 call to _fuzzysearch_char_count()
- fuzzysearch_process in ./
fuzzysearch.module - Process the search query
File
- ./
fuzzysearch.module, line 1028 - Module file for fuzzysearch module.
Code
function _fuzzysearch_char_count($text, $position) {
$bytes = 0;
// Count all the continuation bytes from the start until we have found
// $start characters
$bytes = -1;
$chars = -1;
while ($bytes < $position) {
$bytes++;
$c = ord($text[$bytes]);
if ($c < 0x80 || $c >= 0xc0) {
$chars++;
}
}
return $chars;
}