Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some Special Characters (™) not showing up when ouptutted to web page 1

Status
Not open for further replies.

monkey64

Technical User
Apr 27, 2008
69
0
0
GB
I have an issue with certain special characters not showing up when I output them to a web page,

When I view the database, which has the following:
MySQL charset: cp1252 West European (latin1)
MySQL connection collationUTF-8 Unicode (utf8)

When I view the MySQL database in PhpMyAdmin, I can see the German characters as well as some ™ (Trade Mark) symbols.
When I output the contents of the database to a UTF-8 encoded webpage, I get the German characters, but the Trade Mark symbols show as an "unknown" placeholder.

I've tried both:
echo utf8_encode($row['webinfo']);
and
echo htmlentities($row['webinfo']);

What am I doing wrong?
 
To reliably show 'special' characters I would always use the standard HTML entities provided. For trademark, use ™. For others see
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Thanks Johnwm

When I try using htmlentities, I get the German characters, but not the ™. That's th whole problem. Any ideas?
 
The htmlentities function of PHP must be told what encoding to handle as well, unless it's latin-1. In your case, I'd try supplying utf-8.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
>I've tried both:
>echo utf8_encode($row['webinfo']);
>and
>echo htmlentities($row['webinfo']);

Unfortunately, cp1252 is not exactly iso-8859-1! You should do this instead if you send over utf-8 encoded page to the client.
[tt] echo iconv("windows-1252","utf-8",$row['webinfo']);[/tt]
 
Changing the Doctype helps, but I get 2 errors when I validate:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 
You are not building a consistent story.
>When I output the contents of the database to a UTF-8 encoded webpage,...
><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
Besides, don't know what you meant by your response of help. Help what, change what?
 
Tsuji

I tried your code:

echo iconv("windows-1252","utf-8",$row['webinfo']);

and it works and validates perfectly. Thank you.
In my desperation, I tried changing Doctypes and stumbled upon one that gave me the correct output. My last post didn't make much sense, sorry.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top