keep docstrings from PCL bootstrap around
[sbcl.git] / src / code / external-formats / enc-jpn.lisp
blob119ed1dd146bd27e6309850d8cd2b64822103767
1 (in-package "SB!IMPL")
3 ;;; EUC-JP
4 (declaim (inline ucs-to-eucjp eucjp-to-ucs
5 mb-len-as-eucjp eucjp-continuation-byte-p))
7 (defun ucs-to-eucjp (code)
8 (declare (optimize speed (safety 0))
9 (type fixnum code))
10 (if (<= code #x7F) code
11 (get-multibyte-mapper *ucs-to-eucjp-table* code)))
13 (defun eucjp-to-ucs (code)
14 (declare (optimize speed (safety 0))
15 (type fixnum code))
16 (if (<= code #x7F) code
17 (get-multibyte-mapper *eucjp-to-ucs-table* code)))
19 (defun mb-len-as-eucjp (code)
20 (declare (optimize speed (safety 0))
21 (type (unsigned-byte 8) code))
22 (cond ((< code #x80) 1)
23 ((or (= code #x8E) (<= #xA1 code #xFE)) 2)
24 ((= code #x8F) 3)))
26 (defun eucjp-continuation-byte-p (code)
27 (declare (optimize speed (safety 0))
28 (type (unsigned-byte 8) code))
29 (<= #xA1 code #xFE))
31 (define-multibyte-encoding :euc-jp (:euc-jp :eucjp :|eucJP|)
32 ucs-to-eucjp eucjp-to-ucs mb-len-as-eucjp eucjp-continuation-byte-p)
34 ;;; Shift_JIS
35 (declaim (inline ucs-to-sjis sjis-to-ucs
36 mb-len-as-sjis sjis-continuation-byte-p))
38 (defun ucs-to-sjis (code)
39 (declare (optimize speed (safety 0))
40 (type fixnum code))
41 (if (<= code #x7F) code
42 (get-multibyte-mapper *ucs-to-sjis-table* code)))
44 (defun sjis-to-ucs (code)
45 (declare (optimize speed (safety 0))
46 (type fixnum code))
47 (if (<= code #x7F) code
48 (get-multibyte-mapper *sjis-to-ucs-table* code)))
50 (defun mb-len-as-sjis (code)
51 (declare (optimize speed (safety 0))
52 (type (unsigned-byte 8) code))
53 (cond ((or (< code #x80) (<= #xA1 code #xDF)) 1)
54 ((or (<= #x81 code #x9F) (<= #xE0 code #xFC)) 2)))
56 (defun sjis-continuation-byte-p (code)
57 (declare (optimize speed (safety 0))
58 (type (unsigned-byte 8) code))
59 (or (<= #x40 code #x7E) (<= #x80 code #xFC)))
61 (define-multibyte-encoding :shift_jis (:shift_jis :sjis :|Shift_JIS| :cp932)
62 ucs-to-sjis sjis-to-ucs mb-len-as-sjis sjis-continuation-byte-p)