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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

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

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

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

Post by s.dot »

You are probably wanting to use mb_strlen, for use on multi byte strings.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

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

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

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

Post 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
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

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

Post by ddragas »

thank you for reply and help

have a nice day
Post Reply