summaryrefslogtreecommitdiff
path: root/scm/encoding.scm
blob: d500c0c270b20c9f6302bd9ee8e9579961f5d298 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;;;; encoding.scm -- font encoding
;;;;
;;;;  source file of the GNU LilyPond music typesetter
;;;;
;;;; (c) 2004--2008 Jan Nieuwenhuizen <janneke@gnu.org>

(define-public latin1-coding-vector
  #(.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    %% 0x20
    space exclam quotedbl numbersign dollar percent ampersand quoteright
    parenleft parenright asterisk plus comma hyphen period slash
    zero one two three four five six seven
    eight nine colon semicolon less equal greater question
    %% 0x40
    at A B C D E F G
    H I J K L M N O
    P Q R S T U V W
    X Y Z bracketleft backslash bracketright asciicircum underscore
    %% 0x60
    `quoteleft a b c d e f g
    h i j k l m n o
    p q r s t u v w
    x y z braceleft bar braceright asciitilde .notdef
    %% 0x80
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    dotlessi grave acute circumflex tilde macron breve dotaccent
    dieresis .notdef ring cedilla .notdef hungarumlaut ogonek caron
    %% 0xA0
    space exclamdown cent sterling currency yen brokenbar section
    dieresis copyright ordfeminine guillemotleft logicalnot hyphen registered macron
    degree plusminus twosuperior threesuperior acute mu paragraph periodcentered
    cedilla onesuperior ordmasculine guillemotright onequarter onehalf threequarters questiondown
    %% 0xC0
    Agrave Aacute Acircumflex Atilde Adieresis Aring AE Ccedilla
    Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex Idieresis
    Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis multiply
    Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn germandbls
    %% 0xE0
    agrave aacute acircumflex atilde adieresis aring ae ccedilla
    egrave eacute ecircumflex edieresis igrave iacute icircumflex idieresis
    eth ntilde ograve oacute ocircumflex otilde odieresis divide
    oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis))


(define-public (decode-byte-string str)
  "Return vector of glyphname symbols that correspond to string,
assuming that STR is byte-coded using ENCODING-NAME."

  (let* ((len (string-length str))
	 (output-vector (make-vector len '.notdef)))
    (do
	((idx 0 (1+ idx)))
	((>= idx len) output-vector)
      (vector-set! output-vector idx
		   (vector-ref latin1-coding-vector
			       (char->integer (string-ref str idx)))))))