Обсуждение: Inserting greek letters

Поиск
Список
Период
Сортировка

Inserting greek letters

От
Adam Witney
Дата:
Hi,

I have a database fronted with PHP. I want the user to be able to put
scientific notation characters (greek letters really) and store them in the
database.

Do I have to have created the database with UNICODE encoding to do this?
Also, is there anything in the PHP I have to adjust to be able to store the
data and display the data?

Thanks for any help

Adam


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


Re: Inserting greek letters

От
Martijn van Oosterhout
Дата:
On Fri, Nov 26, 2004 at 02:52:18PM +0000, Adam Witney wrote:
> Do I have to have created the database with UNICODE encoding to do this?
> Also, is there anything in the PHP I have to adjust to be able to store the
> data and display the data?

Obviously, your database needs to be able to store the characters.
Unicode is good for this because it can store almost anything, but
depending on the specific character the encoding you're using may be
fine.

As for PHP, you need to have the browser and PHP agree on what
character set they're going to use. Then you set the client encoding
appropriately and PostgreSQL will make sure you get the information you
expect.

As a final note, you could always store your fancy characters as HTML
entities, then you could store them anywhere, but then also PostgrSQL
will not be able to do any conversion for you...

hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Вложения

Re: Inserting greek letters

От
Adam Witney
Дата:
Hi Martijn, thanks for your quick reply...

> As for PHP, you need to have the browser and PHP agree on what
> character set they're going to use. Then you set the client encoding
> appropriately and PostgreSQL will make sure you get the information you
> expect.

Im not sure, where do I set the client encoding?

Thanks

adam


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


Re: Inserting greek letters

От
Martijn van Oosterhout
Дата:
On Fri, Nov 26, 2004 at 03:16:25PM +0000, Adam Witney wrote:
>
> Hi Martijn, thanks for your quick reply...
>
> > As for PHP, you need to have the browser and PHP agree on what
> > character set they're going to use. Then you set the client encoding
> > appropriately and PostgreSQL will make sure you get the information you
> > expect.
>
> Im not sure, where do I set the client encoding?

Execute the command:

SET CLIENT_ENCODING = <whatever PHP/the web browser is using>

Maybe:

Latin1
Latin9
UTF-8
Windows1238

You need to configure one, don't ask me how though, I don't know PHP or
HTML.

--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Вложения

Re: Inserting greek letters

От
Keary Suska
Дата:
on 11/26/04 8:16 AM, awitney@sghms.ac.uk purportedly said:

>> As for PHP, you need to have the browser and PHP agree on what
>> character set they're going to use. Then you set the client encoding
>> appropriately and PostgreSQL will make sure you get the information you
>> expect.
>
> Im not sure, where do I set the client encoding?

AFAIK, you can't and/or don't need to set character encoding. The issues
would be display and data submission. Your best bet for display is to set
the "default_charset" directive, so PHP will always tell the browser the
correct character set to use. PHP shouldn't care about form data content,
and should handle data literally--i.e. decode it into an octet stream. You
may, however, need to call pg_set_client_encoding() (or set the appropriate
environment variable, as the case may be), to ensure that PHP talks to PG
properly. This might mean that all queries must be properly encoded (i.e.
including keywords), and there may be implications here as well. I am not
sure how PG handles commands vs data.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"