Re: Insertion of character inside a TCP frame
"steph.tougard via Sbcl-help" <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.general |
|---|---|
| Message-ID | <4XZxl3T2oAz3y4B5HOg6i-6oahhIvEtc28tbWSIoWGlXsm2bCEt_mbktW8W8w7FQaFACjX_a6THGF5Rnj-BCaOi4atc-OT6qavmh0sMAqt4=@pm.me> |
Thanks for the help, at this point I applied Christophe solution and it worked fine. But I know it's not a long term solution because UCS-2 SMS are sent in UTF-8 so I'll encounter some problems when I'll work on this part. I'll be sure to keep the list updated on my progress if I reach this point, it's a personal project (there are very good SMPP servers and the world does need another one, there are just none in CL). On Tuesday, July 16th, 2024 at 4:49 PM, Jérôme Radix <[email protected]> wrote: > 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