xref: /webtrees/app/Encodings/CP437.php (revision 36779af1bd0601de7819554b13a393f6edb92507)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2021 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program 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 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Encodings;
21
22/**
23 * Convert between Windows Code Page 437 and UTF-8.
24 *
25 * @link https://en.wikipedia.org/wiki/Code_page_437
26 */
27class CP437 extends AbstractEncoding
28{
29    public const NAME = 'CP437';
30
31    protected const TO_UTF8 = [
32        "\x80" => UTF8::LATIN_CAPITAL_LETTER_C_WITH_CEDILLA,
33        "\x81" => UTF8::LATIN_SMALL_LETTER_U_WITH_DIAERESIS,
34        "\x82" => UTF8::LATIN_SMALL_LETTER_E_WITH_ACUTE,
35        "\x83" => UTF8::LATIN_SMALL_LETTER_A_WITH_CIRCUMFLEX,
36        "\x84" => UTF8::LATIN_SMALL_LETTER_A_WITH_DIAERESIS,
37        "\x85" => UTF8::LATIN_SMALL_LETTER_A_WITH_GRAVE,
38        "\x86" => UTF8::LATIN_SMALL_LETTER_A_WITH_RING_ABOVE,
39        "\x87" => UTF8::LATIN_SMALL_LETTER_C_WITH_CEDILLA,
40        "\x88" => UTF8::LATIN_SMALL_LETTER_E_WITH_CIRCUMFLEX,
41        "\x89" => UTF8::LATIN_SMALL_LETTER_E_WITH_DIAERESIS,
42        "\x8A" => UTF8::LATIN_SMALL_LETTER_E_WITH_GRAVE,
43        "\x8B" => UTF8::LATIN_SMALL_LETTER_I_WITH_DIAERESIS,
44        "\x8C" => UTF8::LATIN_SMALL_LETTER_I_WITH_CIRCUMFLEX,
45        "\x8D" => UTF8::LATIN_SMALL_LETTER_I_WITH_GRAVE,
46        "\x8E" => UTF8::LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS,
47        "\x8F" => UTF8::LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE,
48        "\x90" => UTF8::LATIN_CAPITAL_LETTER_E_WITH_ACUTE,
49        "\x91" => UTF8::LATIN_SMALL_LETTER_AE,
50        "\x92" => UTF8::LATIN_CAPITAL_LETTER_AE,
51        "\x93" => UTF8::LATIN_SMALL_LETTER_O_WITH_CIRCUMFLEX,
52        "\x94" => UTF8::LATIN_SMALL_LETTER_O_WITH_DIAERESIS,
53        "\x95" => UTF8::LATIN_SMALL_LETTER_O_WITH_GRAVE,
54        "\x96" => UTF8::LATIN_SMALL_LETTER_U_WITH_CIRCUMFLEX,
55        "\x97" => UTF8::LATIN_SMALL_LETTER_U_WITH_GRAVE,
56        "\x98" => UTF8::LATIN_SMALL_LETTER_Y_WITH_DIAERESIS,
57        "\x99" => UTF8::LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS,
58        "\x9A" => UTF8::LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS,
59        "\x9B" => UTF8::CENT_SIGN,
60        "\x9C" => UTF8::POUND_SIGN,
61        "\x9D" => UTF8::YEN_SIGN,
62        "\x9E" => UTF8::PESETA_SIGN,
63        "\x9F" => UTF8::LATIN_SMALL_LETTER_F_WITH_HOOK,
64        "\xA0" => UTF8::LATIN_SMALL_LETTER_A_WITH_ACUTE,
65        "\xA1" => UTF8::LATIN_SMALL_LETTER_I_WITH_ACUTE,
66        "\xA2" => UTF8::LATIN_SMALL_LETTER_O_WITH_ACUTE,
67        "\xA3" => UTF8::LATIN_SMALL_LETTER_U_WITH_ACUTE,
68        "\xA4" => UTF8::LATIN_SMALL_LETTER_N_WITH_TILDE,
69        "\xA5" => UTF8::LATIN_CAPITAL_LETTER_N_WITH_TILDE,
70        "\xA6" => UTF8::FEMININE_ORDINAL_INDICATOR,
71        "\xA7" => UTF8::MASCULINE_ORDINAL_INDICATOR,
72        "\xA8" => UTF8::INVERTED_QUESTION_MARK,
73        "\xA9" => UTF8::REVERSED_NOT_SIGN,
74        "\xAA" => UTF8::NOT_SIGN,
75        "\xAB" => UTF8::VULGAR_FRACTION_ONE_HALF,
76        "\xAC" => UTF8::VULGAR_FRACTION_ONE_QUARTER,
77        "\xAD" => UTF8::INVERTED_EXCLAMATION_MARK,
78        "\xAE" => UTF8::LEFT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK,
79        "\xAF" => UTF8::RIGHT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK,
80        "\xB0" => UTF8::LIGHT_SHADE,
81        "\xB1" => UTF8::MEDIUM_SHADE,
82        "\xB2" => UTF8::DARK_SHADE,
83        "\xB3" => UTF8::BOX_DRAWINGS_LIGHT_VERTICAL,
84        "\xB4" => UTF8::BOX_DRAWINGS_LIGHT_VERTICAL_AND_LEFT,
85        "\xB5" => UTF8::BOX_DRAWINGS_VERTICAL_SINGLE_AND_LEFT_DOUBLE,
86        "\xB6" => UTF8::BOX_DRAWINGS_VERTICAL_DOUBLE_AND_LEFT_SINGLE,
87        "\xB7" => UTF8::BOX_DRAWINGS_DOWN_DOUBLE_AND_LEFT_SINGLE,
88        "\xB8" => UTF8::BOX_DRAWINGS_DOWN_SINGLE_AND_LEFT_DOUBLE,
89        "\xB9" => UTF8::BOX_DRAWINGS_DOUBLE_VERTICAL_AND_LEFT,
90        "\xBA" => UTF8::BOX_DRAWINGS_DOUBLE_VERTICAL,
91        "\xBB" => UTF8::BOX_DRAWINGS_DOUBLE_DOWN_AND_LEFT,
92        "\xBC" => UTF8::BOX_DRAWINGS_DOUBLE_UP_AND_LEFT,
93        "\xBD" => UTF8::BOX_DRAWINGS_UP_DOUBLE_AND_LEFT_SINGLE,
94        "\xBE" => UTF8::BOX_DRAWINGS_UP_SINGLE_AND_LEFT_DOUBLE,
95        "\xBF" => UTF8::BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT,
96        "\xC0" => UTF8::BOX_DRAWINGS_LIGHT_UP_AND_RIGHT,
97        "\xC1" => UTF8::BOX_DRAWINGS_LIGHT_UP_AND_HORIZONTAL,
98        "\xC2" => UTF8::BOX_DRAWINGS_LIGHT_DOWN_AND_HORIZONTAL,
99        "\xC3" => UTF8::BOX_DRAWINGS_LIGHT_VERTICAL_AND_RIGHT,
100        "\xC4" => UTF8::BOX_DRAWINGS_LIGHT_HORIZONTAL,
101        "\xC5" => UTF8::BOX_DRAWINGS_LIGHT_VERTICAL_AND_HORIZONTAL,
102        "\xC6" => UTF8::BOX_DRAWINGS_VERTICAL_SINGLE_AND_RIGHT_DOUBLE,
103        "\xC7" => UTF8::BOX_DRAWINGS_VERTICAL_DOUBLE_AND_RIGHT_SINGLE,
104        "\xC8" => UTF8::BOX_DRAWINGS_DOUBLE_UP_AND_RIGHT,
105        "\xC9" => UTF8::BOX_DRAWINGS_DOUBLE_DOWN_AND_RIGHT,
106        "\xCA" => UTF8::BOX_DRAWINGS_BOX_DRAWINGS_DOUBLE_UP_AND_HORIZONTAL,
107        "\xCB" => UTF8::BOX_DRAWINGS_DOUBLE_DOWN_AND_HORIZONTAL,
108        "\xCC" => UTF8::BOX_DRAWINGS_DOUBLE_VERTICAL_AND_RIGHT,
109        "\xCD" => UTF8::BOX_DRAWINGS_DOUBLE_HORIZONTAL,
110        "\xCE" => UTF8::BOX_DRAWINGS_DOUBLE_VERTICAL_AND_HORIZONTAL,
111        "\xCF" => UTF8::BOX_DRAWINGS_UP_SINGLE_AND_HORIZONTAL_DOUBLE,
112        "\xD0" => UTF8::BOX_DRAWINGS_UP_DOUBLE_AND_HORIZONTAL_SINGLE,
113        "\xD1" => UTF8::BOX_DRAWINGS_DOWN_SINGLE_AND_HORIZONTAL_DOUBLE,
114        "\xD2" => UTF8::BOX_DRAWINGS_DOWN_DOUBLE_AND_HORIZONTAL_SINGLE,
115        "\xD3" => UTF8::BOX_DRAWINGS_UP_DOUBLE_AND_RIGHT_SINGLE,
116        "\xD4" => UTF8::BOX_DRAWINGS_UP_SINGLE_AND_RIGHT_DOUBLE,
117        "\xD5" => UTF8::BOX_DRAWINGS_DOWN_SINGLE_AND_RIGHT_DOUBLE,
118        "\xD6" => UTF8::BOX_DRAWINGS_DOWN_DOUBLE_AND_RIGHT_SINGLE,
119        "\xD7" => UTF8::BOX_DRAWINGS_VERTICAL_DOUBLE_AND_HORIZONTAL_SINGLE,
120        "\xD8" => UTF8::BOX_DRAWINGS_VERTICAL_SINGLE_AND_HORIZONTAL_DOUBLE,
121        "\xD9" => UTF8::BOX_DRAWINGS_LIGHT_UP_AND_LEFT,
122        "\xDA" => UTF8::BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT,
123        "\xDB" => UTF8::FULL_BLOCK,
124        "\xDC" => UTF8::LOWER_HALF_BLOCK,
125        "\xDD" => UTF8::LEFT_HALF_BLOCK,
126        "\xDE" => UTF8::RIGHT_HALF_BLOCK,
127        "\xDF" => UTF8::UPPER_HALF_BLOCK,
128        "\xE0" => UTF8::GREEK_SMALL_LETTER_ALPHA,
129        "\xE1" => UTF8::LATIN_SMALL_LETTER_SHARP_S,
130        "\xE2" => UTF8::GREEK_CAPITAL_LETTER_GAMMA,
131        "\xE3" => UTF8::GREEK_SMALL_LETTER_PI,
132        "\xE4" => UTF8::GREEK_CAPITAL_LETTER_SIGMA,
133        "\xE5" => UTF8::GREEK_SMALL_LETTER_SIGMA,
134        "\xE6" => UTF8::MICRO_SIGN,
135        "\xE7" => UTF8::GREEK_SMALL_LETTER_TAU,
136        "\xE8" => UTF8::GREEK_CAPITAL_LETTER_PHI,
137        "\xE9" => UTF8::GREEK_CAPITAL_LETTER_THETA,
138        "\xEA" => UTF8::GREEK_CAPITAL_LETTER_OMEGA,
139        "\xEB" => UTF8::GREEK_SMALL_LETTER_DELTA,
140        "\xEC" => UTF8::INFINITY,
141        "\xED" => UTF8::GREEK_SMALL_LETTER_PHI,
142        "\xEE" => UTF8::GREEK_SMALL_LETTER_EPSILON,
143        "\xEF" => UTF8::INTERSECTION,
144        "\xF0" => UTF8::IDENTICAL_TO,
145        "\xF1" => UTF8::PLUS_MINUS_SIGN,
146        "\xF2" => UTF8::GREATER_THAN_OR_EQUAL_TO,
147        "\xF3" => UTF8::LESS_THAN_OR_EQUAL_TO,
148        "\xF4" => UTF8::TOP_HALF_INTEGRAL,
149        "\xF5" => UTF8::BOTTOM_HALF_INTEGRAL,
150        "\xF6" => UTF8::DIVISION_SIGN,
151        "\xF7" => UTF8::ALMOST_EQUAL_TO,
152        "\xF8" => UTF8::DEGREE_SIGN,
153        "\xF9" => UTF8::BULLET_OPERATOR,
154        "\xFA" => UTF8::MIDDLE_DOT,
155        "\xFB" => UTF8::SQUARE_ROOT,
156        "\xFC" => UTF8::SUPERSCRIPT_LATIN_SMALL_LETTER_N,
157        "\xFD" => UTF8::SUPERSCRIPT_TWO,
158        "\xFE" => UTF8::BLACK_SQUARE,
159        "\xFF" => UTF8::NO_BREAK_SPACE,
160    ];
161}
162