mb_strpos index woes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello world.
(my first email)
well, i have this problem with mb_strpos which returns a position for
me.  the position is an index into the string, supposedly.
everything works fine excpet for when i index into the array.
i wish to confirm that the position is the character count not the byte
count into the string.  
thank you very  much.

if i am correct, i would request a change of the word 'character' in
here to mean multi-byte character for clarity sake

mb_strpos() performs multi-byte safe strpos() operation based on number
of characters. needle position is counted from the beginning of the
haystack. First character's position is 0. Second character position is
1, and so on.

code is this:

$french2=<<<SXR
<BR>Il m'arrive d'être égoiste. Je sais.<BR><BR><IMG height=446
src="http://www.u-blog.net/bezabel/img/bdFM-oueb2.jpg"; width=400
border=0><BR>(<A href="http://blogdamned.free.fr/?2005/05";>Blog
DAmned</A>&nbsp;pour en savoir plus)
SXR;

   $match_pos = mb_strpos($target, $split_pattern,
$present_offset,'UTF-8');
	// check for false omitted
    while (($match_pos  || $first)                    && $present_offset
< $len ) {
//   check for 0 omitted

        $diff = $match_pos-$present_offset;
        $word = mb_substr($target, $present_offset, $diff);

         $mb_len = mb_strlen($word);
         if ($mb_len != $diff) if ($debug_my_mb) echo "$mb_len and $diff
are not equal<br>";
         $match_pos2 = $mb_len + $present_offset;
         if ($match_pos2 != $match_pos) if ($debug_my_mb) echo
"$match_pos and $match_pos2 are not equal<br>";

	TEHY ARE EQUAL, HOWEVER
  
        if ($target[$match_pos] != $split_pattern) if ($debug_my_mb)
echo "<br>mismatch of $next_word and $split_pattern<br>";

	SAYS IT IS A MISMATCH

therefore must return character count, not byte count.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux