What effects MySQL connection"s character set
What effects MySQL connection"s character set
am 26.01.2007 21:12:47 von Niel Archer
Hi all
How is the character set of returned data effected? I have a DB using
UTF-8 encoding., PHP is set to use UTF-8 internally. However the MySQL
connection returns Latin1 data. How can I get it to return UTF-8 data
instead.
TIA
Niel
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: What effects MySQL connection"s character set
am 27.01.2007 02:26:59 von bedul
try to configure on the html..
i think on header..
----- Original Message -----
From: "Niel Archer"
To:
Sent: Saturday, January 27, 2007 3:12 AM
Subject: [PHP-DB] What effects MySQL connection's character set
> Hi all
>
> How is the character set of returned data effected? I have a DB using
> UTF-8 encoding., PHP is set to use UTF-8 internally. However the MySQL
> connection returns Latin1 data. How can I get it to return UTF-8 data
> instead.
>
> TIA
>
> Niel
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: What effects MySQL connection"s character set
am 30.01.2007 04:28:50 von dmagick
Niel Archer wrote:
> Hi all
>
> How is the character set of returned data effected? I have a DB using
> UTF-8 encoding., PHP is set to use UTF-8 internally. However the MySQL
> connection returns Latin1 data. How can I get it to return UTF-8 data
> instead.
http://dev.mysql.com/doc/refman/4.1/en/charset-literal.html
Should cover your questions :)
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: What effects MySQL connection"s character set
am 30.01.2007 16:11:51 von Niel Archer
Hi Chris.
Thanks for this. That page didn't actually help, but one of the follow
ups did. Apparently, despite being setup as UTF-8 throughout the Db,
tables, and columns. The returned data still can default to Latin1.
I've forced my test server to return UTF-8 (I hope) and am trying it
out today. Fingers crossed!
Niel
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: What effects MySQL connection"s character set
am 30.01.2007 20:52:55 von Niel Archer
Hi
> Thanks for this. That page didn't actually help, but one of the follow
> ups did. Apparently, despite being setup as UTF-8 throughout the Db,
> tables, and columns. The returned data still can default to Latin1.
> I've forced my test server to return UTF-8 (I hope) and am trying it
> out today. Fingers crossed!
That turned out to be overly optimistic. Even Though the server is
using UTF-8 throughout, it still defaults to latin1 on connections. So
I used the SET NAMES utf8. It still will not work as I expect. I used
the following code to test it.
$Db = new mysqli($Host, $User, $Pass, $Db);
$Db->query("SET NAMES utf8");
$result = $Db->query("SHOW VARIABLES LIKE 'character\_set\_%'");
$count = $result->num_rows;
while ($count):
$dummy = $result->fetch_assoc();
print $dummy['Variable_name'] . " = " . $dummy['Value'] . "\n";
--$count;
endwhile;
print "\ncharacter_set_name: " . $Db->character_set_name() . "\n";
Which results in the following output:
character_set_client = utf8
character_set_connection = utf8
character_set_database = utf8
character_set_results = utf8
character_set_server = utf8
character_set_system = utf8
character_set_name: latin1
I can't find any documentation on PHP's character encoding, beyond the
default_charset directive. Several of the functions/extensions have
documentation, but not PHP itself.
I suspect the problem is with php itself or the mysqli extension,
which was my original thought and reason for my post.
Anyone have any ideas?
Niel
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: What effects MySQL connection"s character set
am 31.01.2007 19:24:58 von Niel Archer
Hi all
Finally identified the problem. Was pretty obvious in retrospect.
The mysqli class (Improved MySQL extension OO style) defaults to
latin1 as a character set, regardless of what PHP is using. Simple
solution is to use the set_charset method (mysqli_set_charset for non OO) on
the object, which will change the connection parameter.
Niel
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: What effects MySQL connection"s character set
am 03.02.2007 09:47:16 von bedul
what i read..
i conclusion. whenever the data is.. is always latin1 right??
if the data seem give strange type (example like japanese font).. it
will stay on latin1 or change into apropriate data
On 2/1/07, Niel Archer wrote:
> Hi all
>
> Finally identified the problem. Was pretty obvious in retrospect.
>
> The mysqli class (Improved MySQL extension OO style) defaults to
> latin1 as a character set, regardless of what PHP is using. Simple
> solution is to use the set_charset method (mysqli_set_charset for non OO) on
> the object, which will change the connection parameter.
>
> Niel
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
akan ada dimana mulut terkunci dan suara tak ada lagi..
saat itu gunakanlah HP untuk melakukan SMS!!
-> ini aliran bedul.. bukan aliran aneh.
tertawa sebelum tertawa didepan RSJ..
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php