Re: [INTERFACES] Escape Characters

Поиск
Список
Период
Сортировка
От John Horncastle
Тема Re: [INTERFACES] Escape Characters
Дата
Msg-id 35948A41.3335A5D@cybersurf.net
обсуждение исходный текст
Ответ на [INTERFACES] Escape Characters  (John Horncastle <horncasj@cybersurf.net>)
Список pgsql-interfaces
Hello Roberto.

I have found a solution to my problem, but I am not sure that it will solve your problem.  To get around my
problem, I tried to preprocess the string that I was inserting, and reading from my database within my
application.  On insert, if I found a '\' character in the string, I added another '\'  character
(\hello=\\hello), on read, I searched for '\\', and elimated one of the '\' characters (\\hello=\hello) .
Unfortunately, as I found out, when I read the string (\\hello) from the database, only one of the '\'
characters was present (\hello).  This of course explained why my preprocessing logic, on the read at least,
did not work.  In short, if you insert a string that resembles '\\hello', it may look wrong, but when your
application requests the same info, it will look like '\hello'.  Keep in mind that if you try the same query
in the psql frontend, the result will look like '\\hello'.

As a side note, I have tested other combinations of the '\' character in various positions in the string
that I was testing, and certain characters that follow the '\' character react different.  Perhaps they are
OS based, but I am not sure.  I will list my tests below:

\Ffe^ObW =Ffe^ObW
\\Ffe^ObW =\\Ffe^ObW
\ffe^ObW=fe^ObW
\Ffe^\bW=Ffe^bW

The most telling of my experiments is the '\ffe^ObW'  example.  The reason for this is that when I used psql
to perform a query on the table, the field that included the 'fe^ObW' data was moved down a row on the
monitor.  There may be other ascii characters in the printable range that will have a strange effect.  I
have not run in to them yet but '\' is an escape character and there may be more related problems.  If the
'\' character is inserted without preprocessing, certain lowercase letters precursored by the '\' character
may have adverse effects, for example '\n', '\b', '\r', '\t'.

John

Roberto Joao Lopes Garcia wrote:

> Hi John
>
> Do you have any resplay to your question about scape characters?
>
> I have the same problem and I can't find a solution.
>
> I'm using postgreSQL 6.3.2 in an sun solaris 2.5. I use for test the pslq  monitor and  try '\''  == '''
>   '\\'  == '\\'
>
> Could you replay to me any help you have?
>
> Thank you
>
> Roberto
>
> >I am trying to insert/update information in a char field, and
> >unfortunately the information can include any of the printable ascii
> >characters.  The problem that I am having is that ocassionally a "\"
> >character is present and is subsequently ignored when the data is
> >inserted/updated.  I have tried inserting and additional "\", but the
> >data inserted/updated then contains two "\" characters.  If anyone could
> >
> >help, I would appreciate it.  Thanks in advance.
> >
> >John
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------------------------------------
> Eng. Roberto Joao Lopes Garcia         E-mail: roberto@mha.com.br
> F. 55 11 848 9906   FAX  55 11 848 9955
>
> MHA Engenharia de Projetos Ltda
> E-mail: mha@mha.com.br    WWW: http://www.mha.com.br
>
> Av Maia Coelho Aguiar, 215 Bloco D     2 Andar
> Centro Empresarial de Sao Paulo
> Sao Paulo - BRASIL - 05805 000
> ---------------------------------------------------------------------------------------------------




В списке pgsql-interfaces по дате отправления:

Предыдущее
От: "Adrian Camero"
Дата:
Сообщение: Help with JDBC for postgresql
Следующее
От: Wilson MacGyver
Дата:
Сообщение: sub