Forum Moderators: coopster

Message Too Old, No Replies

PHP or MySQL entities problem

Input OK, storage OK, display not

         

Notawiz

3:26 pm on Jun 30, 2005 (gmt 0)

10+ Year Member



A user entered following text in a form:
But they won’t… if it is not
(fine)

The default charset in php.ini is ISO8859-15, and all echoed pages also have a meta content-type with that same charset.

When displayed in a webpage, the text reads as:

But they won?t? if it is not
(wrong)
(in fact little squares with a question mark, and the same are in the markup source code)

When checked in PHPMyAdmin, the string reads as:

But they won’t… if it is not
(fine)

In other words, there are no entities in this string as it has been written in MySQL from the form.

But even though, the display has unknown characters?

Any idea as what went wrong?
Or how to manipulate the MySQL result so that it will display correctly on screen?

I don't understand how it comes that an input without entities can go one way but not the other?

Thank you in advance for your help.
Notawiz

jatar_k

4:26 pm on Jun 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the little three dots, if it comes from MSWord, is actually an unknown char, I always have to replace them, as are hyphens and quotes from Word

ergophobe

5:06 pm on Jun 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Often it's from Word, but this is not limited to Word and to the extent that it is, only specific Word versions. Recent versions of Word use Unicode, but older versions (as well as WordPerfect and many Windows apps before conversion to Unicode) used Win-1252 character set. Macs of a similar vintage have a similar character set and similar issues.

This thread and the links there should answer all you questions:

[webmasterworld.com...]

Notawiz

2:17 pm on Jul 5, 2005 (gmt 0)

10+ Year Member



Hello jatar_k & ergophobe,

Sory to come back late, but for some reason the email notification didn't work.

Your replies might be a good guess, indeed.

We have a form with many input fields, and also a huge textarea where the user has to enter his presentation text.
So chances are indeed that many of them do their "homework" on WORD, and then paste that piece of text in the form when they go online.

Your answers were of a great help.

I've also read your long contribution (post #8 of [webmasterworld.com...]

I was wondering though, since our generated pages as well as php.ini are set to ISO8859-15 (for support of EURO sign), could I use your code:

mb_detect_order("utf-8, windows-1252");
if (mb_detect_encoding($string) == "Windows-1252") {
$string = mb_convert_encoding($string, UTF-8, Windows-1252);
}

as is, or should I replace utf-8 by iso8859-15 to make it work properly?

Regards.
Notawiz