]> git.donarmstrong.com Git - lilypond.git/blob - scm/encoding.scm
Update source file headers. Fixes using standard GNU package conventions.
[lilypond.git] / scm / encoding.scm
1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;;
3 ;;;; Copyright (C) 2004--2009 Jan Nieuwenhuizen <janneke@gnu.org>
4 ;;;;
5 ;;;; LilyPond is free software: you can redistribute it and/or modify
6 ;;;; it under the terms of the GNU General Public License as published by
7 ;;;; the Free Software Foundation, either version 3 of the License, or
8 ;;;; (at your option) any later version.
9 ;;;;
10 ;;;; LilyPond is distributed in the hope that it will be useful,
11 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ;;;; GNU General Public License for more details.
14 ;;;;
15 ;;;; You should have received a copy of the GNU General Public License
16 ;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
17
18 (define-public latin1-coding-vector
19   #(.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
20     .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
21     .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
22     .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
23     %% 0x20
24     space exclam quotedbl numbersign dollar percent ampersand quoteright
25     parenleft parenright asterisk plus comma hyphen period slash
26     zero one two three four five six seven
27     eight nine colon semicolon less equal greater question
28     %% 0x40
29     at A B C D E F G
30     H I J K L M N O
31     P Q R S T U V W
32     X Y Z bracketleft backslash bracketright asciicircum underscore
33     %% 0x60
34     `quoteleft a b c d e f g
35     h i j k l m n o
36     p q r s t u v w
37     x y z braceleft bar braceright asciitilde .notdef
38     %% 0x80
39     .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
40     .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
41     dotlessi grave acute circumflex tilde macron breve dotaccent
42     dieresis .notdef ring cedilla .notdef hungarumlaut ogonek caron
43     %% 0xA0
44     space exclamdown cent sterling currency yen brokenbar section
45     dieresis copyright ordfeminine guillemotleft logicalnot hyphen registered macron
46     degree plusminus twosuperior threesuperior acute mu paragraph periodcentered
47     cedilla onesuperior ordmasculine guillemotright onequarter onehalf threequarters questiondown
48     %% 0xC0
49     Agrave Aacute Acircumflex Atilde Adieresis Aring AE Ccedilla
50     Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex Idieresis
51     Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis multiply
52     Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn germandbls
53     %% 0xE0
54     agrave aacute acircumflex atilde adieresis aring ae ccedilla
55     egrave eacute ecircumflex edieresis igrave iacute icircumflex idieresis
56     eth ntilde ograve oacute ocircumflex otilde odieresis divide
57     oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis))
58
59
60 (define-public (decode-byte-string str)
61   "Return vector of glyphname symbols that correspond to string,
62 assuming that STR is byte-coded using ENCODING-NAME."
63
64   (let* ((len (string-length str))
65          (output-vector (make-vector len '.notdef)))
66     (do
67         ((idx 0 (1+ idx)))
68         ((>= idx len) output-vector)
69       (vector-set! output-vector idx
70                    (vector-ref latin1-coding-vector
71                                (char->integer (string-ref str idx)))))))