Re: postgres8.3beta encodding problem?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: postgres8.3beta encodding problem?
Дата
Msg-id 20071218155403.GF13268@svana.org
обсуждение исходный текст
Ответ на Re: postgres8.3beta encodding problem?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: postgres8.3beta encodding problem?  (Andrew Dunstan <andrew@dunslane.net>)
Re: postgres8.3beta encodding problem?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Tue, Dec 18, 2007 at 10:35:39AM -0500, Tom Lane wrote:
> Martijn van Oosterhout <kleptog@svana.org> writes:
> > Ok, but that doesn't apply in this case, his database appears to be
> > LATIN1 and this character is valid for that encoding...
>
> You know what, I think the test in the code is backwards.
>
>         is_mb = pg_encoding_max_length(encoding) > 1;
>
>         if ((is_mb && (cvalue > 255)) || (!is_mb && (cvalue > 127)))

It does seem to be a bit wierd. For single character encodings anything
up to 255 is OK, well, sort of. It depends on what you want chr() to do
(oh no, not this discussion again). If you subscribe to the idea that
it should use unicode code points then the test is completely bogus,
since whether or not the character is valid has nothing to with whether
the encoding is multibyte or not.

If you want the output of th chr() to (logically) depend on the encoding
then the test makes more sense, but ten it's inverted. Single-byte
encodings are by definition defined to 255 characters. And multibyte
encodings (other than UTF-8 I suppose) can only see the ASCII subset.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
>  -- John F Kennedy

Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: postgres8.3beta encodding problem?
Следующее
От: "Weber, Geoffrey M."
Дата:
Сообщение: Problem with index not being chosen inside PL/PgSQL function...