Re: [GENERAL] Postgres, apps, special characters and UTF-8 encoding
От | vinny |
---|---|
Тема | Re: [GENERAL] Postgres, apps, special characters and UTF-8 encoding |
Дата | |
Msg-id | 66b4ff1fb73dfff6c0143ca239fe60b7@xs4all.nl обсуждение исходный текст |
Ответ на | [GENERAL] Postgres, apps, special characters and UTF-8 encoding (Ken Tanzer <ken.tanzer@gmail.com>) |
Список | 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.
В списке pgsql-general по дате отправления: