Re: octet_length operator: what encoding?

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Chris Angelico *EXTERN*" <rosuav(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: octet_length operator: what encoding?
Date: 2012-03-30 08:10:41
Message-ID: D960CB61B694CF459DCFB4B0128514C207B2C0AA@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chris Angelico wrote:
> We have a number of varchar fields and I'm looking to see what the
> greatest data length in any is, after UTF-8 encoding. The two-argument
> length function appears (I think) to take a byte array, so it's the
> opposite of what I'm looking for (give it a UTF-8 encoded string and
> the second parameter 'UTF-8' and it'll count characters). The
> octet_length function, though, doesn't accept an encoding argument.
> What does it use?

You probably want something like that:

test=> SELECT length(convert_to('schön', 'UTF8'));
length
--------
6
(1 row)

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2012-03-30 08:22:09 Re: default value returned from sql stmt
Previous Message Albe Laurenz 2012-03-30 08:05:53 Re: Re: double check the role has what's kind of the privilege? And the same for the objects. Thanks.