Hello List,
it's been some time .. ;-)
I'm playing around a bit with hex<->ascii conversion in PicoLisp, and I
have the problem that (char 0) = NIL
(hex "00")
-> 0
: (char (hex "00"))
-> NIL
and disappears from the resulting ascii string.
: (setq X
"23230200010001000F003230323
Ah sorry, the moment I sent the question, I figured out the answer :
this is just a side effect of the final (pack ..).
When using (str ...) I get what I want:
: (str (make (while Y (link (char (hex (pack (cut 2 'Y)]
-> "\"#\" \"#\" \"\^B\" NIL NIL NIL \"\^A\" NIL \"\^A\" NIL \"\^O\" NIL NIL
NIL
On Mon 12 Feb 2024 at 23:25, Thorsten Jolitz wrote:
> Shouldn't the (char 0) representation print to something
> like ^N or so too, like (char 1), (char 2) etc?
^@
what are you trying to achieve?
why not use base64, for example?
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscr
I would like to achieve a roundtrip like this:
: (hex (char (char (hex "23"]
-> "23"
but not like this:
: (hex (char (char (hex "01"]
-> "1"
: (hex (char (char (hex "00"]
-> "0"
It should be possible to do this, so that W = X in the end:
: (setq X
"23230200010001000F00323032342D30
On Tue 13 Feb 2024 at 00:25, Thorsten Jolitz wrote:
> I would like to achieve a roundtrip like this:
why?
NUL is often a string sentinel value
so trying to use it as a character value
will lead to issues
do not do that
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Hi Thorsten,
> it's been some time .. ;-)
Welcome back! :)
> I'm playing around a bit with hex<->ascii conversion in PicoLisp, and I
> have the problem that (char 0) = NIL
>
> (hex "00")
> -> 0
> : (char (hex "00"))
> -> NIL
This is correct.
'char' converts a number to a (transient) symbol
Ok I understand that.
But when I have a hexadecimal message string with fixed length, and the
positions inside the string carry semantics? A certain value in a certain
position has a meaning?
Say fixed length is 96 like in the example above, and 2323 ist two start
chars, and then 01 or 02 is a han
Hi Alex,
But shouldn't hex 23232424 print to something like ##^N^N$$ instead of
##$$ ?
So the printed ASCII string (as char) carries all the information from the
hex string, and can be converted back to the exact same hex string?
At least in some special cases when it's needed?
Alexander Burge
On Tue 13 Feb 2024 at 08:28, Thorsten Jolitz wrote:
> But when I have a hexadecimal message string with fixed length, and the
> positions inside the string carry semantics? A certain value in a certain
> position has a meaning?
it is not a string, at least not in picolisp/C/unix sense
you need t