How to write binary lists ?

View: New views
1 Messages — Rating Filter:   Alert me  

How to write binary lists ?

by Ferreira Maurizio-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In attempt to make a litte web server, I'm stuck with the following
problem:

How can I write at once a binary list ?

The following program reads a binary file (an image) and tries to write
it at once to another file
(in the original program the write is made to a stream socket).

However I get the following exception :
   ERROR at  clause 1 of user:go/0 !!
   REPRESENTATION ERROR- charater 255 cannot be encoded in stream 3:
expected character

I tried previously to do a char-by-char output using put_byte, but it is
too slow.

Any suggestion ?

Regards.
Maurizio.

:- use_module(library(readutil)).

go :-
  open('d:\\temp\\border.png',read,S,[type(binary)]),
  read_stream_to_codes(S,List),
  close(S),
  open('d:\\temp\\output.txt',write,S1,[type(binary)]),
  format(S1,"~s",[List]),
  close(S1).

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Yap-users mailing list
Yap-users@...
https://lists.sourceforge.net/lists/listinfo/yap-users