searching for characters via the hexidecimal value

Поиск
Список
Период
Сортировка
Искать

searching for characters via the hexidecimal value

От:
Geoffrey Myers <lists@serioustechnology.com>
Дата:
Is there a way to search for a character in the database by the 
hexidecimal value of that character?

-- 
Until later, Geoffrey

"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson

Re: searching for characters via the hexidecimal value

От:
"Massa, Harald Armin" <chef@ghum.de>
Дата:
yes, there is.

select <your columns> from <your table> where

<your_text_search_column> like '%'||chr(x'42'::int)||'%'

where '42' is your hexadecimal character value.

Be sure to read and understand everything you can find about encodings; and make sure the hexadecimal value you are searching for is from the same encoding.

Best wishes,

Harald

On Mon, Jan 24, 2011 at 16:00, Geoffrey Myers <lists@serioustechnology.com> wrote:
Is there a way to search for a character in the database by the hexidecimal value of that character?

--
Until later, Geoffrey

"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
GHUM GmbH
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607

Amtsgericht Stuttgart, HRB 734971
-
persuadere.
et programmare

Re: searching for characters via the hexidecimal value

От:
Geoffrey Myers <lists@serioustechnology.com>
Дата:
Massa, Harald Armin wrote:
> yes, there is.
> 
> select  from  where
> 
>  like '%'||chr(x'42'::int)||'%'

This does not work for me, but if I convert the hex value to octal this 
does work:

select comments from fax where comments ~* E'\231';

> 
> where '42' is your hexadecimal character value.
> 
> Be sure to read and understand everything you can find about encodings; 
> and make sure the hexadecimal value you are searching for is from the 
> same encoding.
> 
> Best wishes,
> 
> Harald
> 
> On Mon, Jan 24, 2011 at 16:00, Geoffrey Myers 
> > wrote:
> 
>     Is there a way to search for a character in the database by the
>     hexidecimal value of that character?
> 
>     -- 
>     Until later, Geoffrey
> 
>     "I predict future happiness for America if they can prevent
>     the government from wasting the labors of the people under
>     the pretense of taking care of them."
>     - Thomas Jefferson
> 
>     -- 
>     Sent via pgsql-general mailing list (pgsql-general@postgresql.org
>     )
>     To make changes to your subscription:
>     http://www.postgresql.org/mailpref/pgsql-general
> 
> 
> 
> 
> -- 
> GHUM GmbH
> Harald Armin Massa
> Spielberger Straße 49
> 70435 Stuttgart
> 0173/9409607
> 
> Amtsgericht Stuttgart, HRB 734971
> -
> persuadere.
> et programmare


-- 
Until later, Geoffrey

"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson

Re: searching for characters via the hexidecimal value

От:
Jasen Betts <jasen@xnet.co.nz>
Дата:
On 2011-01-24, Geoffrey Myers  wrote:
> Massa, Harald Armin wrote:
>
> This does not work for me, but if I convert the hex value to octal this 
> does work:
>
> select comments from fax where comments ~* E'\231';
>

you can do hex like this:

select comments from fax where comments ~* E'\x99';

or if your hex is unicode

 select comments from fax where comments ~* U&'\2122';


http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html

-- 
⚂⚃ 100% natural
FAQ