1<?php 2 3/** 4 * webtrees: online genealogy 5 * 'Copyright (C) 2023 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 1251 and UTF-8. 24 * 25 * @link https://en.wikipedia.org/wiki/Windows-1251 26 */ 27class Windows1251 extends AbstractEncoding 28{ 29 public const NAME = 'CP1251'; 30 31 protected const TO_UTF8 = [ 32 "\x80" => UTF8::CYRILLIC_CAPITAL_LETTER_DJE, 33 "\x81" => UTF8::CYRILLIC_CAPITAL_LETTER_GJE, 34 "\x82" => UTF8::SINGLE_LOW_9_QUOTATION_MARK, 35 "\x83" => UTF8::CYRILLIC_SMALL_LETTER_GJE, 36 "\x84" => UTF8::DOUBLE_LOW_9_QUOTATION_MARK, 37 "\x85" => UTF8::HORIZONTAL_ELLIPSIS, 38 "\x86" => UTF8::DAGGER, 39 "\x87" => UTF8::DOUBLE_DAGGER, 40 "\x88" => UTF8::EURO_SIGN, 41 "\x89" => UTF8::PER_MILLE_SIGN, 42 "\x8A" => UTF8::CYRILLIC_CAPITAL_LETTER_LJE, 43 "\x8B" => UTF8::SINGLE_LEFT_POINTING_ANGLE_QUOTATION_MARK, 44 "\x8C" => UTF8::CYRILLIC_CAPITAL_LETTER_NJE, 45 "\x8D" => UTF8::CYRILLIC_CAPITAL_LETTER_KJE, 46 "\x8E" => UTF8::CYRILLIC_CAPITAL_LETTER_TSHE, 47 "\x8F" => UTF8::CYRILLIC_CAPITAL_LETTER_DZHE, 48 "\x90" => UTF8::CYRILLIC_SMALL_LETTER_DJE, 49 "\x91" => UTF8::LEFT_SINGLE_QUOTATION_MARK, 50 "\x92" => UTF8::RIGHT_SINGLE_QUOTATION_MARK, 51 "\x93" => UTF8::LEFT_DOUBLE_QUOTATION_MARK, 52 "\x94" => UTF8::RIGHT_DOUBLE_QUOTATION_MARK, 53 "\x95" => UTF8::BULLET, 54 "\x96" => UTF8::EN_DASH, 55 "\x97" => UTF8::EM_DASH, 56 "\x98" => UTF8::REPLACEMENT_CHARACTER, 57 "\x99" => UTF8::TRADE_MARK_SIGN, 58 "\x9A" => UTF8::CYRILLIC_SMALL_LETTER_LJE, 59 "\x9B" => UTF8::SINGLE_RIGHT_POINTING_ANGLE_QUOTATION_MARK, 60 "\x9C" => UTF8::CYRILLIC_SMALL_LETTER_NJE, 61 "\x9D" => UTF8::CYRILLIC_SMALL_LETTER_KJE, 62 "\x9E" => UTF8::CYRILLIC_SMALL_LETTER_TSHE, 63 "\x9F" => UTF8::CYRILLIC_SMALL_LETTER_DZHE, 64 "\xA0" => UTF8::NO_BREAK_SPACE, 65 "\xA1" => UTF8::CYRILLIC_CAPITAL_LETTER_SHORT_U, 66 "\xA2" => UTF8::CYRILLIC_SMALL_LETTER_SHORT_U, 67 "\xA3" => UTF8::CYRILLIC_CAPITAL_LETTER_JE, 68 "\xA4" => UTF8::CURRENCY_SIGN, 69 "\xA5" => UTF8::CYRILLIC_CAPITAL_LETTER_GHE_WITH_UPTURN, 70 "\xA6" => UTF8::BROKEN_BAR, 71 "\xA7" => UTF8::SECTION_SIGN, 72 "\xA8" => UTF8::CYRILLIC_CAPITAL_LETTER_IO, 73 "\xA9" => UTF8::COPYRIGHT_SIGN, 74 "\xAA" => UTF8::CYRILLIC_CAPITAL_LETTER_UKRANIAN_IE, 75 "\xAB" => UTF8::LEFT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK, 76 "\xAC" => UTF8::NOT_SIGN, 77 "\xAD" => UTF8::SOFT_HYPHEN, 78 "\xAE" => UTF8::REGISTERED_SIGN, 79 "\xAF" => UTF8::CYRILLIC_CAPITAL_LETTER_YI, 80 "\xB0" => UTF8::DEGREE_SIGN, 81 "\xB1" => UTF8::PLUS_MINUS_SIGN, 82 "\xB2" => UTF8::CYRILLIC_CAPITAL_LETTER_BYELORUSSIAN_UKRAINIAN_I, 83 "\xB3" => UTF8::CYRILLIC_SMALL_LETTER_BYELORUSSIAN_UKRAINIAN_I, 84 "\xB4" => UTF8::CYRILLIC_SMALL_LETTER_GHE_WITH_UPTURN, 85 "\xB5" => UTF8::MICRO_SIGN, 86 "\xB6" => UTF8::PILCROW_SIGN, 87 "\xB7" => UTF8::MIDDLE_DOT, 88 "\xB8" => UTF8::CYRILLIC_SMALL_LETTER_IO, 89 "\xB9" => UTF8::NUMERO_SIGN, 90 "\xBA" => UTF8::CYRILLIC_SMALL_LETTER_UKRANIAN_IE, 91 "\xBB" => UTF8::RIGHT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK, 92 "\xBC" => UTF8::CYRILLIC_SMALL_LETTER_JE, 93 "\xBD" => UTF8::CYRILLIC_CAPITAL_LETTER_DZE, 94 "\xBE" => UTF8::CYRILLIC_SMALL_LETTER_DZE, 95 "\xBF" => UTF8::CYRILLIC_SMALL_LETTER_YI, 96 "\xC0" => UTF8::CYRILLIC_CAPITAL_LETTER_A, 97 "\xC1" => UTF8::CYRILLIC_CAPITAL_LETTER_BE, 98 "\xC2" => UTF8::CYRILLIC_CAPITAL_LETTER_VE, 99 "\xC3" => UTF8::CYRILLIC_CAPITAL_LETTER_GHE, 100 "\xC4" => UTF8::CYRILLIC_CAPITAL_LETTER_DE, 101 "\xC5" => UTF8::CYRILLIC_CAPITAL_LETTER_IE, 102 "\xC6" => UTF8::CYRILLIC_CAPITAL_LETTER_ZHE, 103 "\xC7" => UTF8::CYRILLIC_CAPITAL_LETTER_ZE, 104 "\xC8" => UTF8::CYRILLIC_CAPITAL_LETTER_I, 105 "\xC9" => UTF8::CYRILLIC_CAPITAL_LETTER_SHORT_I, 106 "\xCA" => UTF8::CYRILLIC_CAPITAL_LETTER_KA, 107 "\xCB" => UTF8::CYRILLIC_CAPITAL_LETTER_EL, 108 "\xCC" => UTF8::CYRILLIC_CAPITAL_LETTER_EM, 109 "\xCD" => UTF8::CYRILLIC_CAPITAL_LETTER_EN, 110 "\xCE" => UTF8::CYRILLIC_CAPITAL_LETTER_O, 111 "\xCF" => UTF8::CYRILLIC_CAPITAL_LETTER_PE, 112 "\xD0" => UTF8::CYRILLIC_CAPITAL_LETTER_ER, 113 "\xD1" => UTF8::CYRILLIC_CAPITAL_LETTER_ES, 114 "\xD2" => UTF8::CYRILLIC_CAPITAL_LETTER_TE, 115 "\xD3" => UTF8::CYRILLIC_CAPITAL_LETTER_U, 116 "\xD4" => UTF8::CYRILLIC_CAPITAL_LETTER_EF, 117 "\xD5" => UTF8::CYRILLIC_CAPITAL_LETTER_HA, 118 "\xD6" => UTF8::CYRILLIC_CAPITAL_LETTER_TSE, 119 "\xD7" => UTF8::CYRILLIC_CAPITAL_LETTER_CHE, 120 "\xD8" => UTF8::CYRILLIC_CAPITAL_LETTER_SHA, 121 "\xD9" => UTF8::CYRILLIC_CAPITAL_LETTER_SHCHA, 122 "\xDA" => UTF8::CYRILLIC_CAPITAL_LETTER_HARD_SIGN, 123 "\xDB" => UTF8::CYRILLIC_CAPITAL_LETTER_YERU, 124 "\xDC" => UTF8::CYRILLIC_CAPITAL_LETTER_SOFT_SIGN, 125 "\xDD" => UTF8::CYRILLIC_CAPITAL_LETTER_E, 126 "\xDE" => UTF8::CYRILLIC_CAPITAL_LETTER_YU, 127 "\xDF" => UTF8::CYRILLIC_CAPITAL_LETTER_YA, 128 "\xE0" => UTF8::CYRILLIC_SMALL_LETTER_A, 129 "\xE1" => UTF8::CYRILLIC_SMALL_LETTER_BE, 130 "\xE2" => UTF8::CYRILLIC_SMALL_LETTER_VE, 131 "\xE3" => UTF8::CYRILLIC_SMALL_LETTER_GHE, 132 "\xE4" => UTF8::CYRILLIC_SMALL_LETTER_DE, 133 "\xE5" => UTF8::CYRILLIC_SMALL_LETTER_IE, 134 "\xE6" => UTF8::CYRILLIC_SMALL_LETTER_ZHE, 135 "\xE7" => UTF8::CYRILLIC_SMALL_LETTER_ZE, 136 "\xE8" => UTF8::CYRILLIC_SMALL_LETTER_I, 137 "\xE9" => UTF8::CYRILLIC_SMALL_LETTER_SHORT_I, 138 "\xEA" => UTF8::CYRILLIC_SMALL_LETTER_KA, 139 "\xEB" => UTF8::CYRILLIC_SMALL_LETTER_EL, 140 "\xEC" => UTF8::CYRILLIC_SMALL_LETTER_EM, 141 "\xED" => UTF8::CYRILLIC_SMALL_LETTER_EN, 142 "\xEE" => UTF8::CYRILLIC_SMALL_LETTER_O, 143 "\xEF" => UTF8::CYRILLIC_SMALL_LETTER_PE, 144 "\xF0" => UTF8::CYRILLIC_SMALL_LETTER_ER, 145 "\xF1" => UTF8::CYRILLIC_SMALL_LETTER_ES, 146 "\xF2" => UTF8::CYRILLIC_SMALL_LETTER_TE, 147 "\xF3" => UTF8::CYRILLIC_SMALL_LETTER_U, 148 "\xF4" => UTF8::CYRILLIC_SMALL_LETTER_EF, 149 "\xF5" => UTF8::CYRILLIC_SMALL_LETTER_HA, 150 "\xF6" => UTF8::CYRILLIC_SMALL_LETTER_TSE, 151 "\xF7" => UTF8::CYRILLIC_SMALL_LETTER_CHE, 152 "\xF8" => UTF8::CYRILLIC_SMALL_LETTER_SHA, 153 "\xF9" => UTF8::CYRILLIC_SMALL_LETTER_SHCHA, 154 "\xFA" => UTF8::CYRILLIC_SMALL_LETTER_HARD_SIGN, 155 "\xFB" => UTF8::CYRILLIC_SMALL_LETTER_YERU, 156 "\xFC" => UTF8::CYRILLIC_SMALL_LETTER_SOFT_SIGN, 157 "\xFD" => UTF8::CYRILLIC_SMALL_LETTER_E, 158 "\xFE" => UTF8::CYRILLIC_SMALL_LETTER_YU, 159 "\xFF" => UTF8::CYRILLIC_SMALL_LETTER_YA, 160 ]; 161} 162