(in-package :cl-user)
;样例数据
(defvar str
"H4sIAAAAAAAAAE2STUvDQBCG/0puOdXdpIGkMG7ZJtMabDdhsxU85aBFCtqCgviTPHlQKPhxEEFB
Lx69+AsELx49iLvdfPSyPO/MO7szw0L/4uTYOZ+dns2Xi23X26KuM1scLA/niyNn23FHg123zyCb
KgY7yBOUDJTkooyzBJlHQx9Iq2E4FUmZJsyPoi6QWoHEPJOqVPs5MuoB2dSQikLZckpNstVQoEz5
uBQZ8yIa0EC/F/S63R6QNgMJ5pU/pF4EpNUwwFEqyoQrZD61VwDZCALqBi2RFmPUvZmbSUMShzbS
QL2MOBMKhd6OLPJqCj15I4DHsSnQrekOfF+PSH0vDLWnylgHnyB7unn9Wv3dPa8u338+3q5/bz8f
vx9e7q8qq7GszfFUv0saMlAoO8QGG+RK1VaLhgZ8XMXWpI9SpRO7oQ4NOusd1UHge7yuaKiZmZh/
8Q+1v/5CQwIAAA==")
;取当前目录
(defun getcurdir nil
(multiple-value-bind (len dir) (WIN32:GetCurrentDirectoryA 260)
(string-concat dir "\\")))
(defparameter *gzip-path* (string-concat (getcurdir) "gzip.exe"))
;解压 gzip字符流
(defun get-unzip-text nil
(let ((out (make-pipe-output-stream (string-concat *gzip-path* " " "-c -d") :element-type '(unsigned-byte 8))))
(unwind-protect
(write-byte-sequence
(convert-string-to-bytes (clipboard) charset:base64)
out)
(close out))))
;解码 gzip编码的字节流
;调用命令:gzip -c -d file
(defun get-unzip-text nil
(let ((*gzip-path* (string-concat (getcurdir) "gzip.exe")));重设当前gzip路径
(multiple-value-bind (io in out) (make-pipe-io-stream (string-concat *gzip-path* " " "-c -d") :element-type '(unsigned-byte 8))
(unwind-protect
(progn
(write-byte-sequence
(convert-string-to-bytes (clipboard) charset:base64)
io)
(close out)
(convert-string-from-bytes
(coerce
(loop for x = (read-byte io nil) while x collect x)
'vector)
charset:gbk))
(close io)))))
;测试
(defun test-1 nil
(setf (clipboard) str)
(get-unzip-text))
;样例数据
(defvar str
"H4sIAAAAAAAAAE2STUvDQBCG/0puOdXdpIGkMG7ZJtMabDdhsxU85aBFCtqCgviTPHlQKPhxEEFB
Lx69+AsELx49iLvdfPSyPO/MO7szw0L/4uTYOZ+dns2Xi23X26KuM1scLA/niyNn23FHg123zyCb
KgY7yBOUDJTkooyzBJlHQx9Iq2E4FUmZJsyPoi6QWoHEPJOqVPs5MuoB2dSQikLZckpNstVQoEz5
uBQZ8yIa0EC/F/S63R6QNgMJ5pU/pF4EpNUwwFEqyoQrZD61VwDZCALqBi2RFmPUvZmbSUMShzbS
QL2MOBMKhd6OLPJqCj15I4DHsSnQrekOfF+PSH0vDLWnylgHnyB7unn9Wv3dPa8u338+3q5/bz8f
vx9e7q8qq7GszfFUv0saMlAoO8QGG+RK1VaLhgZ8XMXWpI9SpRO7oQ4NOusd1UHge7yuaKiZmZh/
8Q+1v/5CQwIAAA==")
;取当前目录
(defun getcurdir nil
(multiple-value-bind (len dir) (WIN32:GetCurrentDirectoryA 260)
(string-concat dir "\\")))
(defparameter *gzip-path* (string-concat (getcurdir) "gzip.exe"))
;解压 gzip字符流
(defun get-unzip-text nil
(let ((out (make-pipe-output-stream (string-concat *gzip-path* " " "-c -d") :element-type '(unsigned-byte 8))))
(unwind-protect
(write-byte-sequence
(convert-string-to-bytes (clipboard) charset:base64)
out)
(close out))))
;解码 gzip编码的字节流
;调用命令:gzip -c -d file
(defun get-unzip-text nil
(let ((*gzip-path* (string-concat (getcurdir) "gzip.exe")));重设当前gzip路径
(multiple-value-bind (io in out) (make-pipe-io-stream (string-concat *gzip-path* " " "-c -d") :element-type '(unsigned-byte 8))
(unwind-protect
(progn
(write-byte-sequence
(convert-string-to-bytes (clipboard) charset:base64)
io)
(close out)
(convert-string-from-bytes
(coerce
(loop for x = (read-byte io nil) while x collect x)
'vector)
charset:gbk))
(close io)))))
;测试
(defun test-1 nil
(setf (clipboard) str)
(get-unzip-text))