Skip site navigation (1) Skip section navigation (2)

Re: Can you check in SQL if a fields can be encoded using specified charset

From: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
To: paul_t100(at)fastmail(dot)fm
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Can you check in SQL if a fields can be encoded using specified charset
Date: 2010-11-17 20:55:49
Message-ID: m2vd3vpt4a.fsf@2ndQuadrant.fr (view raw or flat)
Thread:
Lists: pgsql-general
Paul Taylor <paul_t100(at)fastmail(dot)fm> writes:

> Is there a function that can say whether a textvalue can be encoded in a
> particular charset

See convert() and friends here:

  http://www.postgresql.org/docs/9.0/interactive/functions-string.html#FUNCTIONS-STRING-OTHER

That will issue an error when the text can't be converted, but you could
have a plpgsql function catching the exception for you and returning
false. Won't be very fast, but will do the job.

Regards,
-- 
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support

In response to

pgsql-general by date

Next:From: Dimitri FontaineDate: 2010-11-17 21:03:23
Subject: Re: Adding data from mysql to postgresql periodically
Previous:From: Marc MaminDate: 2010-11-17 20:39:05
Subject: Re: Counting boolean values (how many true, how many false)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group