Re: [q-lang-users] null problemo
Brought to you by:
agraef
From: Tim H. <q...@st...> - 2004-08-30 21:17:42
|
Dr....@t-... (Albert Graef) writes: > Hi, Tim! > > Tim Haynes wrote: >> I'm trying to write a little utility to read & (manipulate &) write PNM >> bitmap image files. > > Have you considered using Q's ImageMagick module for that purpose? Yes, ish. I just wanted to be perverse and do it myself rather than dig around to see how imagemagick worked.. :) >> Reading is OK but I've had to declare that `ord ""=0' around my reader >> function[1]; I'm having serious problems writing the ascii NUL byte out - >> have tried declaring that `chr 0="\0"' and other variations on a theme, but >> every time I try to fwritec the thing, the file truncates prematurely; >> running hexdump shows that no byte in the output is set to 00. > > Yes, Q strings are 0-terminated, as in C, therefore you can't have a \0 > in a string (if you do, the string will be truncated there). > > What you probably need are byte strings. These are especially useful for > encoding arbitrary binary data. See Section 12.3 (Clib -> Byte Strings) of > the manual. Also see the section on binary files for operations on how to > read and write such binary data from/to a file. Right. Thanks a lot. I'll look into those. :) ~Tim -- <http://spodzone.org.uk/> |