Re: PQunescapeBytea code

From: "Jeroen T(dot) Vermeulen" <jtv(at)xs4all(dot)nl>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: PQunescapeBytea code
Date: 2003-10-30 20:31:31
Message-ID: 20031030203130.GG48224@xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 30, 2003 at 08:24:13PM +0100, Jeroen T. Vermeulen wrote:
>
> Then the whole loop could become something like this:

Okay, that code wasn't entirely correct but it gets the idea across. In
C++ terms, what I arrived at was:

string result;
for (int i=0; i<F.size(); ++i)
{
unsigned char c = p[i];
if (c == '\\')
{
c = p[++i];
if (isdigit(c) && isdigit(p[i+1]) && isdigit(p[i+2]))
{
c = (VAL(p[c])<<9) | (VAL(p[i+1])<<3) | VAL(p[i+2]);
i += 2;
}
}
result += char(c);
}

Simple, no?

Jeroen

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message scott.marlowe 2003-10-30 20:53:04 Re: Deadlock problem
Previous Message Jeroen T. Vermeulen 2003-10-30 19:24:13 PQunescapeBytea code