Re[2]: Unicode problems
| From: | ANR Daemon | Date: | Sat, 27 Sep 2008 19:50:51 +0000 |
| Subject: | Re[2]: Unicode problems | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-281055@lists.php.net to get a copy of this message | ||
Greetings, "Thiago H. Pojda".
In reply to Your message dated Friday, September 26, 2008, 18:33:22,
>> I had similar problems, I cant get the whole situation out of what you
>> wrote but here are two hints.
>>
>> If you got SSH Access you can try to import the DB by following command
>>
> I don't have SSH access :/
>>
>> Otherwise if you can't access the server on this way you can set the whole
>> DB connection on the PHP application to the wanted charset by using
>> following function "mysql_set_charset" - but as this one just works on PHP
>> 5.2.3 you can do the same (not recommendet way) over the "Set names"
>> MysqlQuery - this Query just needs to be run after the connection has been
>> established (mysql_connect()).
>>
> Tried without success.
>> Just have a look at the doc of the mysql_set_charset function there you see
>> on the third comment a implementation of this function for all who have an
>> earlier PHP Version than 5.2.3 (
>>
>> http://de3.php.net/manual/de/function.mysql-set-charset.php)
>>
>> Hope I could help.
> Actually all the responses did help. While I was researching I figured some
> weird stuff. I tried MySQL 4.0 examples for CAST() and CONVERT() and all I
> got were syntax errors. This DB is broke.
> I did the following:
> 1) Extract the DB script from the working one;
> 2) Manually added "CHARSET=utf8" for each create table;
> 3) Converted this script to UTF8 and opened with a ANSI reader and all the
> accented chars got funny. Great! That's what I wanted.
> 4) Applied the script into the database and more frustration. *Some* lines
> were in utf8 and some in latin1.
> I can only imagine the hosting is forcing this kind of behaviour so the
> client has to switch DBMS. (I don't see how, but well).
> I'm still trying and researching. If anyone else have any idea, please
> reply.
Well, it is much OT in PHP group, but see.
What you said database does not have latin1, that cant be true.
Try
SHOW CHARACTER SET;
that should list all available charsets.
Then set connection to receive your data in right encoding.
SET NAMES encoding;
Or, if you're using right version of PHP, simply use
mysql_set_charset('encoding');
--
Sincerely Yours, ANR Daemon <anrdaemon@freemail.ru>