htmlentities doesn't convert apostrophe ’

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
kamel
Forum Newbie
Posts: 7
Joined: Mon Jul 31, 2006 3:33 am

htmlentities doesn't convert apostrophe ’

Post by kamel »

Hi all sorry for the banal question but i'm new to the charset question and i think that i need to get
a lot of knowledge about that argument.
My problem is that i use iso-8859-15 like charset into my webpage to show particular character like € and so on.
I have passed to htmlentities the string containing this charset but seem to doesn't work.
I have write a snipped of code to show the problem:

Code: Select all

<!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="it" lang="it">
<head>
<title>::: [ Test special chars ] :::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
</head>
<body>
<?php
$test = '’';
$test = htmlentities($test, ENT_COMPAT, 'ISO-8859-15');
echo $test;
echo '&euro;';
?>
</body>
</html>
I hope that anybody can help me to understand what is the problem
Thanks to all in advance.
User avatar
ronverdonk
Forum Commoner
Posts: 34
Joined: Sat Jun 10, 2006 7:06 am
Location: Netherlands

Post by ronverdonk »

HTMLENTITIES does not translate the opening and closing paragraphs.
You'll have to do that another way.
kamel
Forum Newbie
Posts: 7
Joined: Mon Jul 31, 2006 3:33 am

Post by kamel »

Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have try to change the charset to iso-8859-1 and now seem to work.
I have supposed that iso-8859-15 extend with other characters iso-8859-1.
Now i have placed a snippet of code.

Code: Select all

<html>
<head>
<title>::: [ Test special chars ] :::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
$str = 'th char: ’';
$str = htmlentities($str, ENT_COMPAT, 'iso-8859-1');
echo $str;
?>
</body>
</html>

Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
kamel
Forum Newbie
Posts: 7
Joined: Mon Jul 31, 2006 3:33 am

Post by kamel »

ronverdonk wrote:HTMLENTITIES does not translate the opening and closing paragraphs.
You'll have to do that another way.
What are the characters used from opening and closing paragraphs i don't know it.
Post Reply