Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hello people, pls I need help on dis one. Does Php version 5.4.3 support unicode. Cause after lauching d phpinfo page I can't see the uincode section, like larry screenshot it in the 'Making a Universal site' chapter.

Pls help out.

Thank u §☺ much, really appreciate

Link to comment
Share on other sites

Ahahahahah, Antonio, it aint drunk am typing from my blackberry. Will turn the symbol thing off now.

Pls I jst installed Wamp 2.2, and it came with php 5.4.3. But I still can run the unicode.php example, am getting the fig 14.9 answer.

Doesn't php 5.4.3 support unicode. Pls help.

Link to comment
Share on other sites

This is d code :

 

<?php

header ('Content-Type: text/html; charset=UTF-8');

?>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

 

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

 

<body>

 

<?php

$names = array('joάo','ҐѾργζ', 'Anton', 'KamilÐ', 'FranĞiška','愛子', '杰西卡');

 

foreach ($names as $name)

{

echo "<p>$name has ".strlen($name)." characters <br />\n".strtoupper($name)." in capital letters</p>\n";

}

?>

 

</body>

</html>

 

 

The result when i run the code:

joάo has 5 characters

JOάO in capital letters

ҐѾργζ has 10 characters

ҐѾργζ in capital letters

Anton has 5 characters

ANTON in capital letters

KamilÐ has 7 characters

KAMILÐ in capital letters

FranĞiška has 11 characters

FRANĞIšKA in capital letters

愛子 has 6 characters

愛子 in capital letters

杰西卡 has 9 characters

杰西卡 in capital letters

 

My phone browser cannot display the chinesse words.

Thank u §☺ much.

Link to comment
Share on other sites

†ђξ problem here is that, I think there are some setting I need get done that am not getting, I just installed WAMP 2.2 which has PHP 5.4.14, which I belive has unicode support. If †ђξ unicode support where enabled, I will not be getting †ђξ result I posted.

Pls help.

Link to comment
Share on other sites

There is no setting for Unicode in PHP, per se, in that it's always available.

All you need to do is set the content type to UTF-8 either using the PHP header function or with an HTML meta tag.

Beyond that, there's nothing you need to do. All browsers should know how to interpret either to properly display Unicode characters.

 

And like I said, your script above works fine.

What I can't understand though is why all your posts contain all sorts of weird characters.

Link to comment
Share on other sites

  • 3 weeks later...

People pls help me, am nt still geting this thing. Do I have to make any change in my php.ini file fø̲̣̣я̅ my wamp to surport UNICODE. Am using php 5.4.3., wamp 2.2 to be precise. Pls I need full understanding of this thing, mayb I am missing something in the book. Cos according to the book only php 6(php 5.4) has UNICODE support. §☺ pls what am I missing.

Thak you.

Link to comment
Share on other sites

  • 2 weeks later...

This is the code, and someone said it runs fine.

<?php

header ('Content-Type: text/html; charset=UTF-8');

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0

Transitional//EN" " http://www.w3.org/

TR...ransitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/

html; charset=utf-8" />

<title>Untitled Document</title>

</head>

<body>

<?php

$names = array('joάo','ҐѾργζ', 'Anton', 'KamilÐ',

'FranĞiška','愛子', '杰西卡');

foreach ($names as $name)

{

echo "<p>$name has ".strlen($name)." characters

<br />\n".strtoupper($name)." in capital letters</p>

\n";

}

?>

</body>

</html>

 

 

This is the result:

joάo has 5 characters

JOάO in capital letters

ҐѾργζ has 10 characters

ҐѾργζ in capital letters

Anton has 5 characters

ANTON in capital letters

KamilÐ has 7 characters

KAMILÐ in capital letters

FranĞiška has 11 characters

FRANĞIšKA in capital letters

愛子 has 6 characters

愛子 in capital letters

杰西卡 has 9 characters

杰西卡 in capital letters. (This can be crosschecked on page 444 of the book).

 

According to the book, the result above will be gotten if am using php 5.2 or less. But am using php5.4.3, which I belive is php6, which according to the book has unicode support.

Have already defaulted my dreamweaver to utf-8 encoding.

So pls what could be worng. And one more thing when I call the phpinfo() I can't see section for unicode settings.Pls help out.

Link to comment
Share on other sites

According to the book, larry said php 5.2 will give the result I just posted. Am thinking maybe I have to do somethings in my php.ini file. Or shld I jst reinstall the wamp 2.2.

Am very sorry if am disturbing HartleySan, just don't like not geting a part of a book am reading, I find it hard to move on to other chapters.

Link to comment
Share on other sites

Like I have already said multiple times, I tested your script, and it worked fine in my environment and the results you have posted here (several times) seems fine as well. Please tell me what you think the problem is, or I can no longer help.

Thank you.

Link to comment
Share on other sites

@damilola

Perhaps your phone doesn't support utf-8?

And that is the problem?

 

@anyone

I just changed the code a little to add detect encoding.

I was surprised to see that 'Anton' has come out as ASCI

Why not UTF-8?

<?php
header ('Content-Type: text/html; charset=UTF-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" " http://www.w3.org/
TR...ransitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/
html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$names = array('joάo','ҐѾργζ', 'Anton', 'KamilÐ',
'FranĞiška','愛子', '杰西卡');
foreach ($names as $name)
{
echo "<p>$name has ".strlen($name)." characters
<br />\n".strtoupper($name)." in capital letters
<br />\n".mb_detect_encoding($name)."
</p>
\n";
}
?>
</body>
</html>

Link to comment
Share on other sites

Thank u §☺ much @hartlySan and StephenM, I really appreciate u all.

Now going by the book and the authour, on page 423 we can have 2 result of d Script 14.2 based on the version of php u are running(which has been displayed above), which are the following:

 

U get this when running php6:

 

joάo has 4 characters

JOάO in capital letters

 

ҐѾργζ has 7 characters

ҐѾργζ in capital letters

 

Anton has 5 characters

ANTON in capital letter

s

KamilÐ has 5 characters

KAMILÐ in capital letters

 

FranĞiška has 6 characters

FRANĞIšKA in capital letters

 

愛子 has 2 characters

愛子 in capital letters

 

杰西卡 has 3 characters

杰西卡 in capital letters

 

U get this when running under Php5.2:

 

joάo has 5 characters

JOάO in capital letters

 

ҐѾργζ has 10 characters

ҐѾργζ in capital letters

 

Anton has 5 characters

ANTON in capital letters

 

KamilÐ has 7 characters

KAMILÐ in capital letters

 

FranĞiška has 11 characters

FRANĞIšKA in capital letters

 

愛子 has 6 characters

愛子 in capital letters

 

杰西卡 has 9 characters

杰西卡 in capital letters

 

Now d issue is that am using php 5.4.3, which according to what have seen and read from the net is that php 5.4 is the latest version of php, php 6 is not yet out there.

§☺ since am using Php 5.4.3, y am I get a result for php 5.2 or below ?. Pls this is my main problem, am a beignner with php and I have found it hard to move forward, cos ave been stuck witb dis issue for alomst a month now.

Don't mean to take up ur time, jst need help. Thank you so much people.

Link to comment
Share on other sites

The results of this script will be the same in PHP 5.4.3, 5.4 or 5.2. It doesn't matter. This is a very basic script, and Unicode support has been around forever.

I still don't see the problem, and at this point, I'm wondering if you're trying to troll us.

Link to comment
Share on other sites

 Share

×
×
  • Create New...