Unicode, php and postgresql

Unicode, php and postgresql

am 09.12.2003 09:34:34 von Didier Bretin

Hi,

I try to install a 7.4.0 + php for developping an application in unicode.
Apparently I have no problem ;).

But I don't understand enough the documentation of php. My postgresql
server is configured in unicode, and my database is entirely in unicode.
In my php.ini file I set no mbstring variables. When I'm connecting to the
database, I SELECT the data and then I print them, with the charset
utf-8, to the browser and all the characters are correctly displayed.

My question is : is it the right way I don't have to configure anything
in php for dealing with unicode :) ?

And is there anybody else who played with the same configuration as mine ?

Regards.
--
.------------------------------------------------.
.^. | Didier Bretin, France | dbr@informactis.com |
/V\ |-----------------------| www.informactis.com |
// \\ | `------------------------|
/( )\ | Visit: http://www.vim.org/ |
^^-^^ `------------------------------------------------'


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Re: Unicode, php and postgresql

am 09.12.2003 09:59:50 von Michael Glaesemann

Hi Didier!


On Tuesday, December 9, 2003, at 05:34 PM, Didier Bretin wrote:

> Hi,
>
> I try to install a 7.4.0 + php for developping an application in=20
> unicode.
> Apparently I have no problem ;).
>
> But I don't understand enough the documentation of php. My postgresql
> server is configured in unicode, and my database is entirely in=20
> unicode.
> In my php.ini file I set no mbstring variables. When I'm connecting to=20
> the
> database, I SELECT the data and then I print them, with the charset
> utf-8, to the browser and all the characters are correctly displayed.
>
> My question is : is it the right way I don't have to configure anything
> in php for dealing with unicode :) ?

In my (admittedly limited) experience with PHP 4, Unicode, and=20
PostgreSQL, you can go a long way with the setup you descibe, i.e., not=20
using multi-byte string functions. However, all I do is move info in=20
and out of the database: I'm not doing any fancy-pants parsing of the=20
data in PHP=97including data sanity checking (besides preventing SQL=20
insertion). I would *not* recommend doing it as I've done, though it=20
does work for me. It's something I'm working on rectifying in my own=20
code, and rather than have to fix it later, I'd recommend doing it=20
right the first time.

The reason it works is that PHP (at least as of PHP4) is agnostic about=20
the strings. It just takes it from the database and hands them to your=20
code, not trying to read it, parse it, check it, anything unless you=20
explicitly do so in the code.

Again, I don't recommend this (though I've been doing it myself)=20
because I don't believe you'll be able to do proper data=20
checking=97especially if you're using higher order (i.e., not ASCII) code=
=20
points. For me, this means the Japanese that moves into my database is=20
completely unchecked, and like I said, that's Not Good. To do proper=20
checking of the Japanese, I'd need to use $mb_string functions.

I'm interested in hearing other's opinions on this as well,=20
particularly if they think I'm wrong=97I can always learn something!

hth

Michael Glaesemann
grzm myrealbox com


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html