Groups
Sign in
Groups
comp.lang.lisp
Conversations
About
Send feedback
Help
info
Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Learn more
Re: binary file upload with CLISP
31 views
Skip to first unread message
WJ
unread,
Mar 1, 2015, 3:44:38 AM
3/1/15
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Pascal Bourguignon wrote:
> > That's not what I wanted to ask, really, sorry. How can I do it with
> > CLISP; CLISP converts return+linefeed to newline with character
> > streams, and does not allow to switch to binary mode on standard-input.
>
> You could use:
>
> (with-open-file (bin "/dev/stdin" :direction :input
> :element-type (quote (unsigned-byte 8)))
> (loop for byte = (read-byte bin nil nil)
> for count = 0 then (mod (1+ count) 16)
> while byte
> do (when (zerop count) (terpri)) (format t "~2,'0X " byte)))
>
>
> $ clisp -q -ansi -x '(with-open-file (bin "/dev/stdin" :direction :input
> :element-type (quote (unsigned-byte 8)))
> (loop for byte = (read-byte bin nil nil)
> for count = 0 then (mod (1+ count) 16)
> while byte
> do (when (zerop count) (terpri)) (format t "~2,'\''0X " byte)))' \
> < /tmp/vm87963318553
> [1]>
> 47 49 46 38 39 61 0C 00 0C 00 D5 00 00 FF FF FF
> F7 F7 FF F7 F7 F7 EF EF F7 EF EF EF DE E6 F7 CE
> D6 EF CE D6 E6 C5 D6 E6 B5 C5 EF AD BD E6 A5 BD
> EF 9C B5 EF 94 AD EF 94 AD DE 94 A5 CE 8C A5 D6
> 84 A5 E6 8C A5 CE 8C 9C C5 73 94 DE 73 8C C5 63
> 8C E6 63 8C DE 63 84 D6 5A 84 DE 63 84 BD 52 84
> D6 5A 7B C5 52 7B D6 52 7B CE 52 7B C5 52 7B BD
> 4A 7B CE 4A 73 CE 4A 73 C5 52 73 AD 4A 6B BD 42
> 6B C5 42 6B BD 42 63 B5 3A 63 B5 3A 63 AD 3A 5A
> AD 3A 5A A5 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 2C 00 00
> 00 00 0C 00 0C 00 00 08 8C 00 01 00 08 70 C0 C1
> 85 0B 10 10 08 00 B0 90 80 83 0C 16 12 2C 68 D0
> C1 01 01 86 0F 33 0C 10 08 60 81 08 07 02 10 74
> B8 C0 A0 E3 85 81 21 4C 20 80 B0 21 43 04 03 14
> 30 08 1C 61 02 02 87 0E 1E 42 E8 34 00 20 81 89
> 13 20 38 7C F0 30 62 84 02 00 05 4A A0 48 01 42
> C2 89 12 27 50 F0 2C 91 62 E9 83 03 55 53 A8 D0
> 50 41 85 D7 15 0A 1F B0 F0 7A 00 80 0A 16 2C 1E
> 34 14 CB A2 2C DA 07 17 05 0A 38 30 81 04 89 09
> 07 16 0A 08 08 00 3B
Gauche Scheme:
(use srfi-42) ; do-ec
(do-ec
(:port byte (index i) (standard-input-port) read-byte)
(format #t "~a~2,'0X " (if (zero? (mod i 16)) "\n" "") byte))
73 74 75 66 66 0D 0A 73 74 75 66 66 0D 0A 73 74
75 66 66 0D 0A 73 74 75 66 66 0D 0A 73 74 75 66
66 0D 0A 2E 2E 2E 0D 0A 2E 2E 2E 0D 0A 2F 2F 5B
73 74 61 72 74 5D 0D 0A 31 2E 20 52 65 61 64 20
54 68 69 73 20 74 65 78 74 20 68 65 72 65 0D 0A
32 2E 20 52 65 61 64 20 54 68 69 73 20 74 65 78
74 20 68 65 72 65 0D 0A 33 2E 20 52 65 61 64 20
54 68 69 73 20 74 65 78 74 20 68 65 72 65 0D 0A
2F 2F 5B 65 6E 64 5D 0D 0A 2E 2E 2E 0D 0A 2E 2E
2E 0D 0A
WJ
unread,
Mar 2, 2015, 8:39:37 AM
3/2/15
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
(use gauche.sequence) ; map-to
(display (map-to <string> (^s (integer->char (string->number s 16)))
(string-split
"73 74 75 66 66 0D 0A 73 74 75 66 66 0D 0A 73 74
75 66 66 0D 0A 73 74 75 66 66 0D 0A 73 74 75 66
66 0D 0A 2E 2E 2E 0D 0A 2E 2E 2E 0D 0A 2F 2F 5B
73 74 61 72 74 5D 0D 0A 31 2E 20 52 65 61 64 20
54 68 69 73 20 74 65 78 74 20 68 65 72 65 0D 0A
32 2E 20 52 65 61 64 20 54 68 69 73 20 74 65 78
74 20 68 65 72 65 0D 0A 33 2E 20 52 65 61 64 20
54 68 69 73 20 74 65 78 74 20 68 65 72 65 0D 0A
2F 2F 5B 65 6E 64 5D 0D 0A 2E 2E 2E 0D 0A 2E 2E
2E 0D 0A" #/\s+/)))
stuff
stuff
stuff
stuff
stuff
...
...
//[start]
1. Read This text here
2. Read This text here
3. Read This text here
//[end]
...
...
WJ
unread,
Jan 13, 2016, 9:39:57 PM
1/13/16
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Why this is marked as abuse?
It has been marked as abuse.
Report not abuse
MatzLisp (Ruby):
No looping is needed.
puts IO.binread('test.csv').each_byte.map{|b| format "%02x", b}.
each_slice(16).map{|a| a.join ' '}
===>
4e 61 6d 65 2c 61 67 65 2c 73 65 78 0d 0a 54 6f
6d 2c 33 33 2c 4d 0d 0a 42 69 6c 6c 2c 32 32 2c
4d 0d 0a
--
87-year-old Ursula Haverbeck has been sentenced to imprisonment in Germany for
doubting that people were "exterminated" by "gassing" in the Nazi concentration
camp in Auschwitz.
nationalvanguard.org/2015/11/germany-still-occupied-ursula-haverbeck-sentenced-to-ten-months-for-doubting-jewish-holocaust-stories/
0 new messages