From 39878d64754019f323f8cc790658d883b0df774e Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 25 Dec 2022 12:53:07 +0100 Subject: [PATCH] - wrapped 'babel:string-to-octets' in 'text-utils:string->octets'. --- src/gemini/client.lisp | 2 +- src/gopher/client.lisp | 8 ++++---- src/gui/json-rpc-communication.lisp | 4 ++-- src/package.lisp | 1 + src/text-utils.lisp | 5 ++++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gemini/client.lisp b/src/gemini/client.lisp index 529816b..591f439 100644 --- a/src/gemini/client.lisp +++ b/src/gemini/client.lisp @@ -384,7 +384,7 @@ (if (not (db:tofu-passes-p host cert-hash)) (error 'gemini-tofu-error :host host) (progn - (write-sequence (babel:string-to-octets request) ssl-stream) + (write-sequence (string->octets request) ssl-stream) (force-output ssl-stream) (multiple-value-bind (status description meta response) (parse-response ssl-stream) diff --git a/src/gopher/client.lisp b/src/gopher/client.lisp index 231c09d..3fd3fcf 100644 --- a/src/gopher/client.lisp +++ b/src/gopher/client.lisp @@ -50,10 +50,10 @@ +response-terminal+)))))) (let* ((socket (open-socket host port)) (stream (usocket:socket-stream socket))) - (write-sequence (babel:string-to-octets (format nil - "~a~a" - selector - +request-terminal+)) + (write-sequence (string->octets (format nil + "~a~a" + selector + +request-terminal+)) stream) (finish-output stream) (let* ((buffer (misc:make-fresh-array +response-read-buffer-size+ diff --git a/src/gui/json-rpc-communication.lisp b/src/gui/json-rpc-communication.lisp index ddc5e89..b2835d2 100644 --- a/src/gui/json-rpc-communication.lisp +++ b/src/gui/json-rpc-communication.lisp @@ -34,7 +34,7 @@ (defgeneric send-to-client (object)) (defmethod send-to-client ((object string)) - (send-to-client (babel:string-to-octets object))) + (send-to-client (string->octets object))) (defmethod send-to-client ((object vector)) (write-sequence object *server-output-stream*) @@ -73,7 +73,7 @@ (defgeneric send-to-server (object)) (defmethod send-to-server ((object string)) - (send-to-server (babel:string-to-octets object))) + (send-to-server (string->octets object))) (defmethod send-to-server ((object vector)) (write-sequence object *server-stream*) diff --git a/src/package.lisp b/src/package.lisp index 2d76e4a..0028de6 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -394,6 +394,7 @@ :utf8-encoded-p :clean-unprintable-chars :to-s + :string->octets :strcat :strcat* :join-with-strings diff --git a/src/text-utils.lisp b/src/text-utils.lisp index 7d30978..0070621 100644 --- a/src/text-utils.lisp +++ b/src/text-utils.lisp @@ -96,6 +96,9 @@ (defmethod to-s (object &key &allow-other-keys) (format nil "~a" object)) +(defun string->octets (s &optional (suppress-errors-p nil)) + (babel:string-to-octets s :errorp suppress-errors-p)) + (defun clean-unprintable-chars (string) (cl-ppcre:scan-to-strings "[\\p{Letter}\\p{Number}\\p{Punctuation}]+" string)) @@ -176,7 +179,7 @@ (defun split-lines (text) (let ((res ())) - (flex:with-input-from-sequence (stream (babel:string-to-octets text)) + (flex:with-input-from-sequence (stream (string->octets text)) (loop for line-as-array = (misc:read-line-into-array stream) while line-as-array do (push (text-utils:to-s line-as-array) res)))