Hi Thorsten,

I agree with the others, that's not a string you are processing.
Strictly speaking, PicoLisp text functions and PicoLisp strings (and symbol names) must not contain NULL character.

How about processing this fixed-size values in binary, using (rd 'cnt) and (wr 'cnt) ?

Important: The alternative argument of (rd) makes it work very differently, the default behavior with 'sym argument is for PLIO (the picolisp binary format). It's also usually a bad idea to mix binary and text processing when working with the same input channel, unless you really know about how picolisp text procressing works (the character buffering, with a character potentially being 1-4 bytes), so careful with that.

Greetings,
beneroth

On 13.02.24 20:30, Thorsten Jolitz wrote:
Hi Alex, Thomas,
thanks for your input, this is actually what I was looking for :
image.png
or even better:
image.png
I wonder if there actually is a way to directly print ^@ in PicoLisp for a "non-printable" hex "00", instead of NIL? Wrt the application, I just have to deal with fixed length hex strings (!) where the values at certain offsets carry semantics, conversions are done, and it's crucial that values stay in that position, the NUL values matter. And I don't want to write a PicoLisp application for this, I just wanted an easy way to produce the expected conversion result in PicoLisp as a reference for comparison, and the above solution is fine for that.

Am Di., 13. Feb. 2024 um 09:09 Uhr schrieb Alexander Burger <picolisp@software-lab.de>:

    Hi Thorsten,

    > But shouldn't hex 232300002424 print to something like ##^N^N$$
    instead of
    > ##$$ ?

    The problem is that you try to handle binary data as symbols. This
    is not a good
    idea. Binary data are numbers.

    First of all, do you really have a hex message? Where does
    it come from? Normally I would expect a list of numbers
    as obtained with e.g.

       (make (do 96 (link (rd 1))))

    If it is really a hexadecimal string, you can obtain the list
    of numbers with

       : (make (for (L (chop "232300002424") (cut 2 'L)) (link (hex @))))
       -> (35 35 0 0 36 36)

    ☺/ A!ex

-- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to