Automatic detection of client encoding

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Automatic detection of client encoding
Дата
Msg-id Pine.LNX.4.44.0305281722190.2023-100000@peter.localdomain
обсуждение исходный текст
Ответы Re: Automatic detection of client encoding  (Tatsuo Ishii <t-ishii@sra.co.jp>)
Re: Automatic detection of client encoding  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Automatic detection of client encoding  (Karel Zak <zakkr@zf.jcu.cz>)
Список pgsql-hackers
It is a common problem that a server uses a nontrivial character set
encoding (e.g., Unicode) but users forget to set an appropriate
client-side encoding.  Then they get bogus displays for non-ASCII
characters because their client isn't actually prepared for Unicode.

There is a standard interface (SUSv2) for detecting the character set
based on the locale settings.  I suggest we use this (if available) in
applications like psql and pg_dump by default unless it is overridden by
the usual mechanisms.  If the character set name obtained this way is not
recognized by PostgreSQL, we fall back to SQL_ASCII.

Here's a piece of code that shows how this would work:

#include <stdio.h>
#include <locale.h>
#include <langinfo.h>

int
main(int argc, char *argv[])
{       setlocale(LC_ALL, "");       printf("%s\n", nl_langinfo(CODESET));       return 0;
}

(LC_CTYPE is the governing category for this.)

Comments?

-- 
Peter Eisentraut   peter_e@gmx.net



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Yurgis Baykshtis"
Дата:
Сообщение: Re: Mismatched parentheses when creating a rule with multiple action queries
Следующее
От: Tatsuo Ishii
Дата:
Сообщение: Re: Automatic detection of client encoding