For Programmers: Free Programming Magazines  


Home > Archive > PHP with PostgreSQL Database > March 2005 > unicode and frensh accents









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author unicode and frensh accents
Zouari Fourat

2005-03-29, 9:02 pm

Hello,
I have a problem displaying frensh data :
my client encoding is set to UNICODE (same as phpPgAdmin)
when selecting data with phpPgAdmin, there's no errors displaying
accents and other special frensh caracters.
but when selecting from my own script i dont get those frensh caracters.
in my html pages i do :
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
like phpPgAdmin and there is allways problems displaying frensh data...
anyone can help ?

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Christopher Kings-Lynne

2005-03-29, 9:02 pm

> I have a problem displaying frensh data :
> my client encoding is set to UNICODE (same as phpPgAdmin)
> when selecting data with phpPgAdmin, there's no errors displaying
> accents and other special frensh caracters.
> but when selecting from my own script i dont get those frensh caracters.
> in my html pages i do :
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
> like phpPgAdmin and there is allways problems displaying frensh data...
> anyone can help ?


Well, you can try sending an http header as well, before ANY of your
script's output:

header('Content-Type: text/html; charset=UTF-8');

Alternatively, try setting the client encoding to unicode with an sql
statement before running any queries, however that should not be
necessary as client encoding defaults to server encoding.

BTW, have a look at the printHeader() method in classes/Misc.php in
phpPgAdmin to see how we do it.

Chris

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Zouari Fourat

2005-03-29, 9:02 pm

in phppgadmin, the statement
header('Content-Type: text/html; charset=UTF-8');

[root@apps pgadmin]# grep -r "header(" *
dataexport.php: header("Location: {$url}");
dataexport.php: header("Location: {$url}");
dataexport.php: header("Location: {$url}");
dataexport.php: header('Content-Type: text/plain');
dataexport.php: header('Content-Type:
application/download');
dataexport.php: header('Content-Disposition:
attachment; filename=dump.' . $ext);
dataexport.php: header('Content-Type: text/plain');
dbexport.php: header('Content-Type: text/plain');
dbexport.php: header('Content-Type:
text/plain');
dbexport.php: header('Content-Type:
application/download');
dbexport.php:
header('Content-Disposition: attachment; filename=dump.sql');
dbexport.php: header('Content-Type:
application/download');
dbexport.php: header('Content-Disposition:
attachment; filename=dump.sql.gz');
help.php: header("Location: $url");
logout.php:header('Location: index.php');

in classes/Misc.php
there's
echo "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset={$lang['appcharset']}\" />\n";

wich result in <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
same as i did ...

there's another thing that can be helpfull tracking my problem.
when getting data well formed in my explorer from phppgadmin and then
saving it to my hard disk and displaying it from its local location i
get the same problems.
and the line :
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
exists !


On Thu, 03 Mar 2005 22:28:04 +0800, Christopher Kings-Lynne
<chriskl@familyhealth.com.au> wrote:
>
> Well, you can try sending an http header as well, before ANY of your
> script's output:
>
> header('Content-Type: text/html; charset=UTF-8');
>
> Alternatively, try setting the client encoding to unicode with an sql
> statement before running any queries, however that should not be
> necessary as client encoding defaults to server encoding.
>
> BTW, have a look at the printHeader() method in classes/Misc.php in
> phpPgAdmin to see how we do it.
>
> Chris
>


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Christopher Kings-Lynne

2005-03-29, 9:02 pm

> there's another thing that can be helpfull tracking my problem.
> when getting data well formed in my explorer from phppgadmin and then
> saving it to my hard disk and displaying it from its local location i
> get the same problems.
> and the line :
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
> exists !


Then I have no idea...

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Zouari Fourat

2005-03-29, 9:02 pm

ok i admit...
that last one is wrong, the page when saved displays well formed data...

but what about header('... charset=UTF-8 statement ? it doesnt occur
in phppgadmin files ...


On Thu, 03 Mar 2005 23:24:27 +0800, Christopher Kings-Lynne
<chriskl@familyhealth.com.au> wrote:
>
> Then I have no idea...
>


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Markus Bertheau

2005-03-29, 9:02 pm

У Чтв, 2005-03-03 у 16:51 +0100, Zouari Fourat пише:
> ok i admit...
> that last one is wrong, the page when saved displays well formed data...
>
> but what about header('... charset=UTF-8 statement ? it doesnt occur
> in phppgadmin files ...


Right, we don't set it. Usually apache does if not told otherwise.

What do you get from your own script? Best make a screenshot.

Markus

--
Markus Bertheau <twanger@bluetwanger.de>

Miroslav Å ulc

2005-03-29, 9:02 pm

NNTP-Posting-Host: news.hub.org
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="------------080405050805080703040906"
X-Trace: news.hub.org 1110013227 85976 200.46.204.72 (5 Mar 2005 09:00:27 GMT)
X-Complaints-To: usenet@news.hub.org
NNTP-Posting-Date: Sat, 5 Mar 2005 09:00:27 +0000 (UTC)
X-Received: from svr1.postgresql.org (svr1.postgresql.org [200.46.204.71])
by news.hub.org (8.13.1/8.13.1) with ESMTP id j2590QYd085967
for <pgsql-php@news.hub.org>; Sat, 5 Mar 2005 09:00:26 GMT
(envelope-from pgsql-php-owner+M3038=pgsql+2Dphp=news.hub.org@postgresql.org)
X-Received: from localhost (unknown [200.46.204.144])
by svr1.postgresql.org (Postfix) with ESMTP id 7B8DC560C5
for <pgsql-php@news.hub.org>; Sat, 5 Mar 2005 09:00:26 +0000 (GMT)
X-Received: from svr1.postgresql.org ([200.46.204.71])
by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024)
with ESMTP id 83064-07 for <pgsql-php@news.hub.org>;
Sat, 5 Mar 2005 09:00:26 +0000 (GMT)
X-Received: from postgresql.org (svr1.postgresql.org [200.46.204.71])
by svr1.postgresql.org (Postfix) with ESMTP id 0C7DE560AF
for <pgsql-php@news.hub.org>; Sat, 5 Mar 2005 09:00:26 +0000 (GMT)
X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org
X-Received: from localhost (unknown [200.46.204.144])
by svr1.postgresql.org (Postfix) with ESMTP id DA14655DD6
for <pgsql-php-postgresql.org@localhost.postgresql.org>; Sat, 5 Mar 2005 08:59:20 +0000 (GMT)
X-Received: from svr1.postgresql.org ([200.46.204.71])
by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024)
with ESMTP id 83064-05
for <pgsql-php-postgresql.org@localhost.postgresql.org>;
Sat, 5 Mar 2005 08:59:17 +0000 (GMT)
X-Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66])
by svr1.postgresql.org (Postfix) with ESMTP id ABC3E55CF0
for <pgsql-php@postgresql.org>; Sat, 5 Mar 2005 08:59:15 +0000 (GMT)
X-Received: (qmail 25350 invoked from network); 5 Mar 2005 09:59:17 +0100
X-Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) (10.15.70.18)
by smtp.klamovka.kosire.czf with AES256-SHA encrypted SMTP; 5 Mar 2005 09:59:17 +0100
X-User-Agent: Mozilla Thunderbird 1.0 (X11/20041208)
X-Accept-Language: en-us, en
X-To: Markus Bertheau <twanger@bluetwanger.de>
X-Cc: Zouari Fourat <fourat@gmail.com>,
Christopher Kings-Lynne <chriskl@familyhealth.com.au>,
pgsql-php@postgresql.org
X-In-Reply-To: <1109982973.4308.6.camel@umnik>
X-Enigmail-Version: 0.89.5.0
X-Enigmail-Supports: pgp-inline, pgp-mime
X-Virus-Scanned: by amavisd-new at hub.org
X-Mailing-List: pgsql-php
X-Precedence: bulk
X-Virus-Scanned: by amavisd-new at hub.org
Xref: news.hub.org pgsql.interfaces.php:84

This is a multi-part message in MIME format.
--------------080405050805080703040906
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Maybe you could send us the code that retrieves the data from PostgreSQL.

I personally use 'pg_set_client_encoding($link, 'UNICODE');' before I
get data from server to be sure I get it in utf-8 encoding. Other thing
that might be a problem is that default apache configuration file
contains 'AddDefaultCharset ISO-8859-1' instruction which sets default
charset in case the apache cannot find one in the page. Disabling this
makes characters unmangled (it may and probably should by solved other
way but I didn't spend my time on figuring how).

Miroslav Å_ulc



Markus Bertheau wrote:

>У Чтв, 2005-03-03 у 16:51 +0100, Zouari Fourat пише:
>
>
>
>Right, we don't set it. Usually apache does if not told otherwise.
>
>What do you get from your own script? Best make a screenshot.
>
>Markus
>
>
>


--------------080405050805080703040906
Content-Type: text/x-vcard; charset=utf-8;
name="miroslav.sulc.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="miroslav.sulc.vcf"

YmVnaW46dmNhcmQNCmZuO3F1b3RlZC1wcmludGFi
bGU6TWlyb3NsYXYgPUM1
PUEwdWxjDQpuO3F1b3RlZC1wcmludGFibGU6PUM1
PUEwdWxjO01pcm9zbGF2
DQpvcmc6U3RhcnROZXQgcy5yLm8uDQphZHI7cXVv
dGVkLXByaW50YWJsZTtx
dW90ZWQtcHJpbnRhYmxlOjs7VnJjaGxpY2s9QzM9
QTlobyAxNjEvNTtQcmFo
YSA1OzsxNTAgMDA7PUM0PThDZXNrPUMzPUExIHJl
cHVibGlrYQ0KZW1haWw7
aW50ZXJuZXQ6bWlyb3NsYXYuc3VsY0BzdGFydG5l
dC5jeg0KdGl0bGU6Q0VP
DQp0ZWw7d29yazorNDIwIDI1NyAyMjUgNjAyDQp0
ZWw7Y2VsbDorNDIwIDYw
MyA3MTEgNDEzDQp4LW1vemlsbGEtaHRtbDpUUlVF
DQp1cmw6aHR0cDovL3d3
dy5zdGFydG5ldC5jeg0KdmVyc2lvbjoyLjENCmVu
ZDp2Y2FyZA0KDQo=

--------------080405050805080703040906
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

--------------080405050805080703040906--

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com