Re: Insertion of character inside a TCP frame

Jérôme Radix <[email protected]>
Newsgroups gmane.lisp.steel-bank.general
Message-ID <CAAyNt779V+xOgbM912NEz=r4eQ=zu5skOSLPy6=sKznnPFkNJA@mail.gmail.com>
Hi Steph,

here is a little strace output (strace.out) showing that :
- you effectively have 22 bytes
- (length answer) returns 21 because of character C2 which is more than 127
and this mess FORMAT and UTF-8 (see Christophe answer)

To help you see the characters in your answer string, in rbind, replace in
sbcl :
(format t "~A (~A)~%" answer (length answer))
by
(format t "~A (~A)~%" (sb-ext:string-to-octets answer) (length
(sb-ext:string-to-octets answer)))

it prints :
#(0 0 0 21 194 128 0 0 1 0 0 0 0 0 0 0 1 83 77 80 80 0) (22)

I would be glad to see your final solution,

Regards,
Jérôme.

Le mar. 16 juil. 2024 à 10:00, Marco Antoniotti <[email protected]>
a écrit :

> Hi Stephane
>
> you may want to have a look at *babel* and maybe *cl-pack* for encoding
> and decoding.  I am sure there are others around and some of them may
> suffer from some bit rot.
>
> All the best
>
> Marco
>
> On Tue, Jul 16, 2024 at 9:49 AM Christophe Rhodes <[email protected]>
> wrote:
>
>> "steph.tougard via Sbcl-help" <[email protected]> writes:
>>
>> > For those who don't know, SMPP is a binary protocol over TCP to send
>> > SMS. Unlike SMPP or HTTP, each frame is sent or received between the
>>
>> SMPP is a binary protocol, but your Lisp code uses characters and
>> strings.  This means that there will be an encoding step on the Lisp
>> side, to convert from characters to binary.
>>
>> In most lisps nowadays, the default encoding scheme is probably utf-8,
>> which encodes the ASCII repertoire (the first 128 characters of Unicode)
>> as single bytes, but uses multiple bytes for all other characters.
>>
>> I would guess that the string that you are attempting to send contains a
>> character with char-code greater than 127, and that your stream is set
>> up to convert characters using utf-8.
>>
>> You are using usocket, which does not allow users to specify external
>> formats directly.  You could try setting
>> sb-ext:*default-external-format* to :latin-1 before starting your
>> server, or you could send binary (rather than string) data to your
>> socket, performing the character to binary conversion yourself rather
>> than making it implicit.
>>
>> Christophe
>>
>>
>> _______________________________________________
>> Sbcl-help mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/sbcl-help
>>
>
>
> --
> Marco Antoniotti, Professor                   tel. +39 - 02 64 48 79 01
> DISCo, University of Milan-Bicocca U14 2043   http://dcb.disco.unimib.it
> Viale Sarca 336
> I-20126 Milan (MI) ITALY
> _______________________________________________
> Sbcl-help mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sbcl-help
>

_______________________________________________
Sbcl-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-help
strace.out (application/octet-stream, 3 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.