File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 95
95
96
96
(defun pointer-to-string (pointer)
97
97
(unless (cffi :null-pointer-p pointer)
98
- (let ((bytes (loop :for i :from 0
99
- :for code := (cffi :mem-aref pointer :unsigned-char i)
100
- :until (zerop code)
101
- :collect code)))
102
- (babel :octets-to-string
103
- (make-array (length bytes)
104
- :element-type ' (unsigned-byte 8 )
105
- :initial-contents bytes)))))
98
+ (let* ((bytes (loop :for i :from 0
99
+ :for code := (cffi :mem-aref pointer :unsigned-char i)
100
+ :until (zerop code)
101
+ :collect code))
102
+ (octets (make-array (length bytes)
103
+ :element-type ' (unsigned-byte 8 )
104
+ :initial-contents bytes)))
105
+ (handler-case (babel :octets-to-string octets)
106
+ (error ()
107
+ ; ; Fallback when an error occurs with UTF-8 encoding
108
+ (map ' string #' code-char octets))))))
106
109
107
110
(defun process-receive-output (process)
108
111
(let ((cffi :*default-foreign-encoding* (process-encode process)))
You can’t perform that action at this time.
0 commit comments