|
Posted by Markus on 07/19/07 12:29
Matthew White schrieb:
> "Markus" <derernst@NO#SP#AMgmx.ch> wrote in message
> news:469db6f9$1_1@news.cybercity.ch...
>> Matthew White schrieb:
>>
>>> "Rik" <luiheidsgoeroe@hotmail.com> wrote in message
>>> news:op.tvmvq3jkqnv3q9@metallium...
>>>> On Tue, 17 Jul 2007 20:31:56 +0200, Matthew White <mgw854@msn.com>
>>>> wrote:
>>>>
>>>>> I added that query right after calling the database, and it now
>>>>> works fine,
>>>>> but here is a problem- "français" returns three matches:
>>>>> français
>>>>> française
>>>>> françaises
>>>>>
>>>>> Why is "ç" being substituted for "ç", even when I pass each
>>>>> returned string
>>>>> through htmlentities()?
[...]
>> It looks like your string is in UTF-8 encoding, but the output is
>> converted to Latin-1 or whatever. Check the following points:
>>
>> 1. All scripts (PHP, HTML) are in UTF-8 encoding
>>
>> 2. Send UTF-8 header to the browser:
>> header('Content-Type: text/html; charset=UTF-8');
>>
>> 3. Set also the appropriate Meta tag in the HTML source (should not be
>> necessary if correct header is sent, but you never know about browsers):
>> <meta http-equiv="content-type" content="text/html;charset=UTF-8">
[...]
>
> I had already made sure of the first and last, but I did add the
> header() to my PHP file. It has made no difference in the output.
Hum... if you don't find the solution in the links posted by Good Man,
you could try to add
ini_set('default_charset', 'utf-8');
to your PHP script (somewhere at the top); but I also think it is rather
a MySQL issue now. BTW, which MySQL version do you use?
One possible reason is that the db contents, that existed before you
added mysql_query("SET NAMES 'utf8'"), are now returned distorted, as
you entered them without telling the DB they are UTF-8, so "ç" was
stored as "ç", which will now be returned in proper UTF-8 encoding. To
test this, make the same test with data you entered after you added the
"SET NAMES" query.
Anyway, if this is the case, it is likely that your original problem
re-arises with all data entered with proper SET NAMES setting!
[Back to original message]
|