Page 1 of 1

string composed of 63 characters => strlen returns 119 ????

Posted: Sun Oct 24, 2010 7:56 am
by ddragas
Hi all
can somebody pls explain me how does strlen work? Shouldn't this function return number of characters?

I've got string composed of 63 characters which strlen returns 119 characters

here is code

Code: Select all


<?php
$string = 'συμβουλευτικών υπηρεσιών στον τομέα των τεχνολογικών εφαρμογών.';
$r = strlen($string);
echo $r;
?>

================
output: 119


thank you all in advance

kind regards

Re: string composed of 63 characters => strlen returns 119 ?

Posted: Sun Oct 24, 2010 8:12 am
by s.dot
You are probably wanting to use mb_strlen, for use on multi byte strings.

Re: string composed of 63 characters => strlen returns 119 ?

Posted: Sun Oct 24, 2010 10:59 am
by ddragas
Thank you for reply

no I wish to calculate number of characters which is 63 not 119

mb_strlen also returns 119 characters

Re: string composed of 63 characters => strlen returns 119 ?

Posted: Sun Oct 24, 2010 11:04 am
by s.dot
Did you specify the character encoding?

e.g.

Code: Select all

$str = 'συμβουλευτικών υπηρεσιών στον τομέα των τεχνολογικών εφαρμογών.';
echo mb_strlen($str, 'UTF-8');
EDIT| Returns 63 - just tested it

Re: string composed of 63 characters => strlen returns 119 ?

Posted: Sun Oct 24, 2010 11:09 am
by ddragas
thank you for reply and help

have a nice day