Re: Postgres, apps, special characters and UTF-8 encoding

From: vinny <vinny(at)xs4all(dot)nl>
To: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>, pgsql-general-owner(at)postgresql(dot)org
Subject: Re: Postgres, apps, special characters and UTF-8 encoding
Date: 2017-03-08 07:54:35
Message-ID: 66b4ff1fb73dfff6c0143ca239fe60b7@xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2017-03-08 00:20, Ken Tanzer wrote:
> Hi. I've got a recurring problem with character encoding for a
> Postgres-based web PHP app, and am hoping someone can clue me in or at
> least point me in the right direction. I'll confess upfront my
> understanding of encoding issues is extremely limited. Here goes.
>

> And that one way or another, the encoding
> needs to be translated before it can be placed into the database.

> Ken
>
> --
>

You don't really have to translate the encoding, because all parts of
the system
are capable of dealing with all encodings.

What you have to make sure that that they are indeed all working in the
same encoding.
You have to set the encoding of the HTML document, the database, and the
database connection
to the same encoding, like utf8. People tend to forget the "set names"
on the database connection,
which can make the database think you are sending latin1, but you are
really sending utf-8, and presto problemo.

Then the only problem left is that PHP doesn't do utf-8 very well
internally
so if you receive data from an UTF-8 page and want to substring etc
then you have to use the multibyte variants
of those functions. You could convert everything back to latin1 first,
but then
you might as well just do everything in latin1 in the first place.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yogesh Sharma 2017-03-08 08:30:10 Re: Request to confirm which command is use for exclusive operation
Previous Message Scott Marlowe 2017-03-08 06:57:28 Re: Request to confirm which command is use for exclusive operation