Re: Oracle 10g / PHP / utf-8

From: Laurenz Albe <>
Date: 20 Nov 2008 16:17:54 GMT
Message-ID: <>

Nico <> wrote:
> On Linux/Apache/PHP5/Oracle Database 10g Express Edition Release
> I checked the script /usr/lib/oracle/xe/app/oracle/product/
> 10.2.0/server/config/scripts/, where the environment var
> NLS_LANG is set to AMERICAN.UTF8. So far so good. It means that the
> client was properly configured.

Oracle's UTF8 is in UNICODE Version 3.0
Oracle's AL32UTF8 is UNICODE Version 4.01

The latter is preferred.

> @Laurenz: From PHP I connect using oci_connect(["Username"],
> ["Password"],["Server"],"AL32UTF8"); The last par is the charset. To
> make sure we are OK in the PHP client, I set the environment var once
> more: putenv("NLS_LANG=_.UTF8");

Again, it should be AL32UTF8.

> Today I have done lots of testing again.
> Surprisingly we had a good situation, without problems with UTF8.
> After recreation of the database with sqlplus in a number of
> environments (production, test, development), data became corrupted.
> Today the UTF8 problem disappeared miraculously. No idea why. And
> exactly that makes me somewhat concerned, since these type of problems
> tend to pop up again exactly when it is really inconvenient.
> So please, I'm just an application developer, not a DBA.
> Could anyone hint me towards a clear understanding of this problem?

If the Client Encoding is set to AL32UTF8, it should work fine. It's a simple as that.

It's hard to say from here why it first didn't work on your computer and now does.

If you change environment variables, you have to restart the process if it should pick them up, but I guess you know that.

Laurenz Albe Received on Thu Nov 20 2008 - 10:17:54 CST

Original text of this message