1 ;;; enc-cn.lisp: CP936 encoding support in SBCL
2 ;;; Chun Tian (binghe) <binghe.lisp@gmail.com>
3 ;;; Sat Dec 23 02:45:12 CST 2006
8 (declaim (inline ucs-to-gbk gbk-to-ucs
9 mb-len-as-gbk gbk-continuation-byte-p
))
11 (defun ucs-to-gbk (code)
12 (declare (optimize speed
(safety 0))
14 (if (<= code
#x7f
) code
15 (get-multibyte-mapper +ucs-to-gbk-table
+ code
)))
17 (defun gbk-to-ucs (code)
18 (declare (optimize speed
(safety 0))
20 (if (<= code
#x7f
) code
21 (get-multibyte-mapper +gbk-to-ucs-table
+ code
)))
23 (defun mb-len-as-gbk (code)
24 (declare (optimize speed
(safety 0))
25 (type (unsigned-byte 8) code
))
26 (if (< code
#x80
) 1 2))
28 (defun gbk-continuation-byte-p (code)
29 (declare (optimize speed
(safety 0))
30 (type (unsigned-byte 8) code
)
34 (declaim (muffle-conditions compiler-note
))
35 (define-multibyte-encoding :gbk
(:gbk
:cp936
)
36 ucs-to-gbk gbk-to-ucs mb-len-as-gbk gbk-continuation-byte-p
)