Re: Cleaning NUL bytes in TEXT column
Posted in 2010
On Tue, Feb 16, 2010 at 14:51, John Hardin <jhardin@epicor.com> wrote: > "Art Kagel" <art.kagel@gmail.com> wrote: > > Read the data with an ESQL/C program, scrub it and update the row. > > Unfortunately we don't have a lot of C+ESQL expertise here. Everything we > do > is 4GL, Delphi and .NET. > > I was thinking of suggesting something similar in .NET to the devs but > wanted to probe alternatives first. Read the blobs with I4GL - located in memory. Sanitize the memory - then write the blobs back again. The sanitize step would still be C code, but roughly: #include "fglsys.h" int sanitize_text(int i) { loc_t *blob; if (i != 1) fgl_fatal(__FILE__, __LINE__, -1318); poplocator(&blob); if (blob->loc_loctype != LOCMEMORY) return(0); char *dst = blob->loc_buffer; char *src = blob->loc_buffer; char *end = src + blob->loc_bufsize; char c; while (src < end) { c = *src++; if (c != '\\0') *dst++ = c; } blob->loc_bufsize = dst - blob->loc_buffer; return(0); } That compiles, but is otherwise untested. Use at your own peril (but let me know if there's anything grotesquely wrong with it, please). -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2008.0513 -- http://dbi.perl.org/ "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." NB: Please do not use this email for correspondence. I don't necessarily read it every week, even. Charles de Gaulle<http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html> - "The better I get to know men, the more I find myself loving dogs." -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2008.0513 -- http://dbi.perl.org/ "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." NB: Please do not use this email for correspondence. I don't necessarily read it every week, even. Ted Turner <http://www.brainyquote.com/quotes/authors/t/ted_turner.html> - "Sports is like a war without the killing."