Problems with foreign characters

Installation and support for Oracle DB on CentOS.
madcapone
Posts: 5
Joined: 2008/04/05 05:19:00

Problems with foreign characters

Postby madcapone » 2008/04/05 05:42:54

Hi all!!

This problem has been driving me nuts these past weeks and I just can't get it solved. I'm not very much familiar with Linux/Unix OS and that might be getting in the way of sorting this thing out.

Here's what's happening. I run applications with languages on ISO-8859-1 (latin). It's an old 9i DB that's been up for at least 8 years. I think it started as v8 and then was upgraded to 9i, but I'm not the DBA, so I'm not sure. What I'm sure is that this DB was created using latin language patterns, and that several applications are currently running fine based on that DB.

So I developed my own PHP web site and hosted it in a shared CentOS4 server which is in en_US. That's when my problems started.

Now every query run through PHP pages returns ? replacing latin characters. That doesn't happen on my testing environment, which is Windows in Brazilian Portuguese (latin language), nor on TOAD. I've run several tests to make sure it's not an Apache or PHP issue, or even HTML headers. Those are all fine. It's a sure thing that the queries are being returned with replaced characters.

Now, here's some info:
OS: CentOS4
Server: Apache 1 stable
Parser: PHP 4 stable
DB: Oracle 9i
Client: 10g v_10.1.3 (not instant client)
Client Install Folder: /u01/app/oracle

HTML Headers:

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


File httpd.conf settings (Apache Config):
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
LanguagePriority pt-BR en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt ru sv zh-CN zh-TW
ForceLanguagePriority Prefer Fallback
AddDefaultCharset ISO-8859-1
AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen

On CentOS, if I run the command locale, that's the output (US English):
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

The output of the command locale -a shows a whole lot of languages, inclusive (these are Brazilian Portuguese and Portugal Portuguese):
pt_BR
pt_BR.iso88591
pt_BR.utf8
pt_PT
pt_PT@euro
pt_PT.iso88591
pt_PT.iso885915@euro
pt_PT.utf8


I've read elsewhere that the Oracle Client will prioritize the OS language settings when returning queries. I don't know if there's any truth in that, but if so, is it possible to override that?

Also some people have told me I might have to edit the NLS_LANG settings in the Oracle Client profile to
NLS_LANG=BRAZILIAN PORTUGUESE_BRAZIL.WE8ISO8859P1
but nobody has been able to tell me where that profile is located, so I don't even know what's it's set to, if anything.


That's all the info I've got.

Any help will be extremely appreciated.

yyagol
Posts: 1015
Joined: 2006/06/10 18:27:44
Location: 32 4&#8242;N 34 47&#8242;E
Contact:

Problems with foreign characters

Postby yyagol » 2008/04/06 05:34:21

This is nothing to do with CentOS , this is a true oracle thing.
you can find the answer on oracle web site . the NLS can be set as env with the parameters you want
http://download.oracle.com/docs/cd/A848 ... 66/ch2.htm
http://download.oracle.com/docs/cd/E121 ... all18.html
be careful before you insert , and make sure the charset are correct ,this can harm the data

madcapone
Posts: 5
Joined: 2008/04/05 05:19:00

Re: Problems with foreign characters

Postby madcapone » 2008/04/11 16:58:55

Hi yyagol! Thanks for your reply.

There's no such thing as "This is nothing to do with CentOS". In fact, one of the sites you suggested explicitly says:

(...) There are four ways to specify NLS parameters:
2. As environment variables on the client. You can use NLS parameters to specify locale-dependent behavior for the client, and also override the defaults set for the session in the initialization file. For example, on a UNIX system:
setenv NLS_SORT FRENCH
(...)


So I think I have to identify whether or not the NLS parameters are set to be locale-dependent. As of now I'm pretty sure that the Apache NLS_LANG is unset.

My question now is: how may I set Apache NLS_LANG environment var through CentOS? (It's been reported that using PutEnv or the globals $_ENV through PHP may result in erratic behavior).



Thanks in advance.

yyagol
Posts: 1015
Joined: 2006/06/10 18:27:44
Location: 32 4&#8242;N 34 47&#8242;E
Contact:

Re: Problems with foreign characters

Postby yyagol » 2008/04/20 11:47:52

Can you point us of this report of erratic behavior when setting PutEnv ?
this is the first time i hear that there is a problem with that setting. i must say the setting of env
using PutEnv will only exist for the duration of the current request. after that the env will be like it was before.
so yes if you change a system env var that can have effect on running process then this can have erratic behavior .
for example setting HOSTNAME env can have effect on a lot of process on the system.

madcapone
Posts: 5
Joined: 2008/04/05 05:19:00

Re: Problems with foreign characters

Postby madcapone » 2008/04/21 15:17:26

I've solved this issued by setting the NLS_LANG env in Apache init. Simple as that.

Thanks for your reply though.

Cheers.