Re: OCTET_LENGTH is wrong - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Re: OCTET_LENGTH is wrong
Date
Msg-id 20011119154843U.t-ishii@sra.co.jp
Whole thread Raw
In response to Re: OCTET_LENGTH is wrong  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
> > What about encoding?
> 
> Single-byte encodings have the same character and byte lengths.  Only
> multi-byte encodings are different, right?
> 
> In thinking about it, I think the function is called octet_length()
> to emphasize is returns the length in octets (bytes) rather than the
> length in characters.

I think Tom's point is whether octet_length() should regard input text
being encoded in the client side encoding or not.

My vote is octet_length() assumes database encodeding.
If you need client side encoded text length, you could do something
like:

select octet_length(convert('foo',pg_client_encoding()));

Note that there was a nasty bug in convert() which prevents above
working. I have committed fixes.
--
Tatsuo Ishii


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: format_type infelicity
Next
From: Alessio Bragadini
Date:
Subject: Re: Open items