"WindAndWaves" <access@ngaru.com> wrote in message
news:OCjMd.14506$mo2.1127368@news.xtra.co.nz...[color=blue]
>
> "Andy Hassall" <andy@andyh.co.uk> wrote in message
> news:3m2001pa76v1og0k0vr0iriev750f42suv@4ax.com...[color=green]
>> On Tue, 1 Feb 2005 21:02:15 +1300, "WindAndWaves" <access@ngaru.com>
>> wrote:
>>[color=darkred]
>> >Here I am writing my first php / mysql site, almost ready, and now
>> >this... charactersets....
>> >
>> >The encoding that I use on my webpage is:
>> >
>> ><META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">[/color]
>>
>> Send a proper character set header; using <meta> for content type and
>> encodings is generally for situations where HTTP headers don't exist,
>> e.g.
>> reading off a filesystem.
>>
>> header("Content-type: text/html; charset=utf-8");
>>
>>
http://uk2.php.net/header[color=darkred]
>> >
>> >When people enter new data I use
>> >
>> >$newvalue = htmlentities($_POST["newvalue"], ENT_QUOTES)[/color]
>>
>> That defaults to ISO-8859-1; if you pass it UTF-8 without setting the
>> third
>> parameter, you'll corrupt your data.
>>
>>
http://uk2.php.net/htmlentities
>>[color=darkred]
>> >I then SQL this into my table and next I display the value
>> >
>> >e.g. <DIV CLASS="content">'.$newvalue.'</DIV>
>> >
>> >All of this works fine, BUT, funny characters that may have been entered
>> >through the form (e.g. Word-Style quotation marks,
>> >e-accent-grave, etc..)[/color]
>>
>> These characters all exist in UTF-8 - as does almost every character.
>>[color=darkred]
>> >are taking on a whole new life. I put in an e with an accent and it
>> >changed into a chinese character.[/color]
>>
>> Can you give a short self-contained example demonstrating it?
>>[color=darkred]
>> >I tried to run
>> >
>> >$link = mysql_connect($host, $username, $password);
>> >$charset = mysql_character_set_name($link);
>> >printf ("character set is %s\n", $charset);
>> >
>> >but that only gave me an error.[/color]
>>
>> According to the manul there's no such function. There's
>> mysqli_character_set_name, from the new PHP5 mysqli extension - but not
>> in the
>> old mysql extension.
>>
>> --
>> Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>[/color]
>
>
> Hi Andy and NC
>
> I since discovered that a lot of functions arenot supported by my
> provider. Namely, UTF-8 is not supported in MySQL[/color]
Wrong. MySQL 4.1 supports various character sets. Take a look at
http://dev.mysql.com/doc/mysql/en/charset.html
[color=blue]
> and PHP does
> not support, for example, the conversion functions that you mention above.[/color]
Wrong again. Take a look at the multi-byte string conversion functions at
http://www.php.net/manual/en/ref.mbstring.php
--
Tony Marston
http://www.tonymarston.net
[color=blue]
> I think I will have to stick with a pretty plane type of characterset and
> make the Japanese pages by hand.
>
> Thank you for your helpful answers.
>
> - Nicolaas
>
>[/color]