X-Git-Url: http://dolda2000.com/gitweb/?p=lisp-utils.git;a=blobdiff_plain;f=charcode.lisp;h=486e679f7531a6a05132c455d933bf4e0e97eebb;hp=ac1c74d40ccd1d7e4313f5c56f61896de72e7a57;hb=dfa6197cf07772bba6cc056c35672b7f8c4d0f3b;hpb=c94c6f05729be13f1433925b0b95c363bb793284 diff --git a/charcode.lisp b/charcode.lisp index ac1c74d..486e679 100644 --- a/charcode.lisp +++ b/charcode.lisp @@ -2,7 +2,7 @@ ;;;; representations thereof (defpackage :charcode - (:use :cl #+sbcl :sb-gray #-sbcl :gray) + (:use :cl) (:export "MAKE-ENCODER" "MAKE-DECODER" "ENCODE-STRING" "DECODE-STRING" "SYSTEM-CHARSET" "NO-CODEC-ERROR" "CODING-ERROR" "MAKE-CODEC-CHARACTER-STREAM" @@ -81,6 +81,10 @@ ;;; Gray stream implementation +;; Disabled for now. There doesn't seem to be any good way to get +;; these working generally over various implementations. + +#+unused ( (defclass codec-character-stream (fundamental-character-input-stream fundamental-character-output-stream) ((decoder :initarg :decoder) (encoder :initarg :encoder) @@ -189,6 +193,7 @@ (let ((outbuf (make-array (list (- end start)) :element-type '(unsigned-byte 8) :adjustable t :fill-pointer 0))) (funcall encoder seq outbuf) (write-sequence outbuf back)))) +) ;;; Implementation-specific functions @@ -202,6 +207,18 @@ (declare (type character char)) (char-code char)) +#+ecl +(defun unicode->char (unicode) + (declare (type (unsigned-byte 24) unicode)) + (when (>= unicode 256) + (error "ECL does not handle Unicode characters outside Latin-1.")) + (code-char unicode)) + +#+ecl +(defun char->unicode (char) + (declare (type character char)) + (char-code char)) + ;;; ASCII (defun decode-ascii (byteseq charseq &key (start 0) (end (length byteseq)))