Re: strange encoding behavior

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: "Jeff Davis *EXTERN*" <jdavis(at)laika(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: strange encoding behavior
Date: 2006-10-23 08:26:34
Message-ID: 52EF20B2E3209443BC37736D00C3C1380B0918F4@EXADV1.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeff Davis wrote:
> I have a UTF8 encoded database. I can do
>
> => SELECT '\xb9'::text;
>
> But that seems to be the only way to get an invalid utf8 byte sequence
> into a text type.
[...]
> So, if I were to sum this up in a single question, why does cstring
not
> accept invalid utf8 sequences? And if it doesn't, why are they allowed
> in any text type?

I would say that it should be impossible to get invalid UTF-8 bytes
into a text on an UTF-8 database, and my opinion is that it is a bug or
oversight if a typecast allows you to do so.

The program you are talking about that needs to be able to store
arbitrary bytes in a text column should be changed - maybe it is enough
to change the data type of the database column from 'text' to 'bytea'.

Yours,
Laurenz Albe

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hervé Piedvache 2006-10-23 12:19:11 Re: Wordpress & PostgreSQL ...
Previous Message brian 2006-10-23 07:44:09 Re: How to determine initdb parameters on old database?