Re: PQunescapeBytea code - Mailing list pgsql-hackers

From Jeroen T. Vermeulen
Subject Re: PQunescapeBytea code
Date
Msg-id 20031030203130.GG48224@xs4all.nl
Whole thread Raw
In response to PQunescapeBytea code  ("Jeroen T. Vermeulen" <jtv@xs4all.nl>)
Responses Re: PQunescapeBytea code
List 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



pgsql-hackers by date:

Previous
From: "Jeroen T. Vermeulen"
Date:
Subject: PQunescapeBytea code
Next
From: Daniel Migowski
Date:
Subject: CREATE TYPE for case insensitive text and varchar