| 1 | #! /bin/false | ||
| 2 | |||
| 3 | # vim: set autoindent shiftwidth=4 tabstop=4: | ||
| 4 | |||
| 5 | # Conversion routines for ISO-8859-1. | ||
| 6 | # Copyright (C) 2002-2026 Guido Flohr <guido.flohr@cantanea.com>, | ||
| 7 | # all rights reserved. | ||
| 8 | |||
| 9 | # This program is free software: you can redistribute it and/or modify | ||
| 10 | # it under the terms of the GNU General Public License as published by | ||
| 11 | # the Free Software Foundation; either version 3 of the License, or | ||
| 12 | # (at your option) any later version. | ||
| 13 | |||
| 14 | # This program is distributed in the hope that it will be useful, | ||
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | # GNU General Public License for more details. | ||
| 18 | |||
| 19 | # You should have received a copy of the GNU General Public License | ||
| 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | package Locale::RecodeData::ISO_8859_1; | ||
| 23 | |||
| 24 | use strict; | ||
| 25 | |||
| 26 | require Locale::RecodeData; | ||
| 27 | use base qw(Locale::RecodeData); | ||
| 28 | |||
| 29 | use constant TO_UTF8 => [ | ||
| 30 | "\x00", | ||
| 31 | "\x01", | ||
| 32 | "\x02", | ||
| 33 | "\x03", | ||
| 34 | "\x04", | ||
| 35 | "\x05", | ||
| 36 | "\x06", | ||
| 37 | "\x07", | ||
| 38 | "\x08", | ||
| 39 | "\x09", | ||
| 40 | "\x0a", | ||
| 41 | "\x0b", | ||
| 42 | "\x0c", | ||
| 43 | "\x0d", | ||
| 44 | "\x0e", | ||
| 45 | "\x0f", | ||
| 46 | "\x10", | ||
| 47 | "\x11", | ||
| 48 | "\x12", | ||
| 49 | "\x13", | ||
| 50 | "\x14", | ||
| 51 | "\x15", | ||
| 52 | "\x16", | ||
| 53 | "\x17", | ||
| 54 | "\x18", | ||
| 55 | "\x19", | ||
| 56 | "\x1a", | ||
| 57 | "\x1b", | ||
| 58 | "\x1c", | ||
| 59 | "\x1d", | ||
| 60 | "\x1e", | ||
| 61 | "\x1f", | ||
| 62 | "\x20", | ||
| 63 | "\x21", | ||
| 64 | "\x22", | ||
| 65 | "\x23", | ||
| 66 | "\x24", | ||
| 67 | "\x25", | ||
| 68 | "\x26", | ||
| 69 | "\x27", | ||
| 70 | "\x28", | ||
| 71 | "\x29", | ||
| 72 | "\x2a", | ||
| 73 | "\x2b", | ||
| 74 | "\x2c", | ||
| 75 | "\x2d", | ||
| 76 | "\x2e", | ||
| 77 | "\x2f", | ||
| 78 | "\x30", | ||
| 79 | "\x31", | ||
| 80 | "\x32", | ||
| 81 | "\x33", | ||
| 82 | "\x34", | ||
| 83 | "\x35", | ||
| 84 | "\x36", | ||
| 85 | "\x37", | ||
| 86 | "\x38", | ||
| 87 | "\x39", | ||
| 88 | "\x3a", | ||
| 89 | "\x3b", | ||
| 90 | "\x3c", | ||
| 91 | "\x3d", | ||
| 92 | "\x3e", | ||
| 93 | "\x3f", | ||
| 94 | "\x40", | ||
| 95 | "\x41", | ||
| 96 | "\x42", | ||
| 97 | "\x43", | ||
| 98 | "\x44", | ||
| 99 | "\x45", | ||
| 100 | "\x46", | ||
| 101 | "\x47", | ||
| 102 | "\x48", | ||
| 103 | "\x49", | ||
| 104 | "\x4a", | ||
| 105 | "\x4b", | ||
| 106 | "\x4c", | ||
| 107 | "\x4d", | ||
| 108 | "\x4e", | ||
| 109 | "\x4f", | ||
| 110 | "\x50", | ||
| 111 | "\x51", | ||
| 112 | "\x52", | ||
| 113 | "\x53", | ||
| 114 | "\x54", | ||
| 115 | "\x55", | ||
| 116 | "\x56", | ||
| 117 | "\x57", | ||
| 118 | "\x58", | ||
| 119 | "\x59", | ||
| 120 | "\x5a", | ||
| 121 | "\x5b", | ||
| 122 | "\x5c", | ||
| 123 | "\x5d", | ||
| 124 | "\x5e", | ||
| 125 | "\x5f", | ||
| 126 | "\x60", | ||
| 127 | "\x61", | ||
| 128 | "\x62", | ||
| 129 | "\x63", | ||
| 130 | "\x64", | ||
| 131 | "\x65", | ||
| 132 | "\x66", | ||
| 133 | "\x67", | ||
| 134 | "\x68", | ||
| 135 | "\x69", | ||
| 136 | "\x6a", | ||
| 137 | "\x6b", | ||
| 138 | "\x6c", | ||
| 139 | "\x6d", | ||
| 140 | "\x6e", | ||
| 141 | "\x6f", | ||
| 142 | "\x70", | ||
| 143 | "\x71", | ||
| 144 | "\x72", | ||
| 145 | "\x73", | ||
| 146 | "\x74", | ||
| 147 | "\x75", | ||
| 148 | "\x76", | ||
| 149 | "\x77", | ||
| 150 | "\x78", | ||
| 151 | "\x79", | ||
| 152 | "\x7a", | ||
| 153 | "\x7b", | ||
| 154 | "\x7c", | ||
| 155 | "\x7d", | ||
| 156 | "\x7e", | ||
| 157 | "\x7f", | ||
| 158 | "\xc2\x80", | ||
| 159 | "\xc2\x81", | ||
| 160 | "\xc2\x82", | ||
| 161 | "\xc2\x83", | ||
| 162 | "\xc2\x84", | ||
| 163 | "\xc2\x85", | ||
| 164 | "\xc2\x86", | ||
| 165 | "\xc2\x87", | ||
| 166 | "\xc2\x88", | ||
| 167 | "\xc2\x89", | ||
| 168 | "\xc2\x8a", | ||
| 169 | "\xc2\x8b", | ||
| 170 | "\xc2\x8c", | ||
| 171 | "\xc2\x8d", | ||
| 172 | "\xc2\x8e", | ||
| 173 | "\xc2\x8f", | ||
| 174 | "\xc2\x90", | ||
| 175 | "\xc2\x91", | ||
| 176 | "\xc2\x92", | ||
| 177 | "\xc2\x93", | ||
| 178 | "\xc2\x94", | ||
| 179 | "\xc2\x95", | ||
| 180 | "\xc2\x96", | ||
| 181 | "\xc2\x97", | ||
| 182 | "\xc2\x98", | ||
| 183 | "\xc2\x99", | ||
| 184 | "\xc2\x9a", | ||
| 185 | "\xc2\x9b", | ||
| 186 | "\xc2\x9c", | ||
| 187 | "\xc2\x9d", | ||
| 188 | "\xc2\x9e", | ||
| 189 | "\xc2\x9f", | ||
| 190 | "\xc2\xa0", | ||
| 191 | "\xc2\xa1", | ||
| 192 | "\xc2\xa2", | ||
| 193 | "\xc2\xa3", | ||
| 194 | "\xc2\xa4", | ||
| 195 | "\xc2\xa5", | ||
| 196 | "\xc2\xa6", | ||
| 197 | "\xc2\xa7", | ||
| 198 | "\xc2\xa8", | ||
| 199 | "\xc2\xa9", | ||
| 200 | "\xc2\xaa", | ||
| 201 | "\xc2\xab", | ||
| 202 | "\xc2\xac", | ||
| 203 | "\xc2\xad", | ||
| 204 | "\xc2\xae", | ||
| 205 | "\xc2\xaf", | ||
| 206 | "\xc2\xb0", | ||
| 207 | "\xc2\xb1", | ||
| 208 | "\xc2\xb2", | ||
| 209 | "\xc2\xb3", | ||
| 210 | "\xc2\xb4", | ||
| 211 | "\xc2\xb5", | ||
| 212 | "\xc2\xb6", | ||
| 213 | "\xc2\xb7", | ||
| 214 | "\xc2\xb8", | ||
| 215 | "\xc2\xb9", | ||
| 216 | "\xc2\xba", | ||
| 217 | "\xc2\xbb", | ||
| 218 | "\xc2\xbc", | ||
| 219 | "\xc2\xbd", | ||
| 220 | "\xc2\xbe", | ||
| 221 | "\xc2\xbf", | ||
| 222 | "\xc3\x80", | ||
| 223 | "\xc3\x81", | ||
| 224 | "\xc3\x82", | ||
| 225 | "\xc3\x83", | ||
| 226 | "\xc3\x84", | ||
| 227 | "\xc3\x85", | ||
| 228 | "\xc3\x86", | ||
| 229 | "\xc3\x87", | ||
| 230 | "\xc3\x88", | ||
| 231 | "\xc3\x89", | ||
| 232 | "\xc3\x8a", | ||
| 233 | "\xc3\x8b", | ||
| 234 | "\xc3\x8c", | ||
| 235 | "\xc3\x8d", | ||
| 236 | "\xc3\x8e", | ||
| 237 | "\xc3\x8f", | ||
| 238 | "\xc3\x90", | ||
| 239 | "\xc3\x91", | ||
| 240 | "\xc3\x92", | ||
| 241 | "\xc3\x93", | ||
| 242 | "\xc3\x94", | ||
| 243 | "\xc3\x95", | ||
| 244 | "\xc3\x96", | ||
| 245 | "\xc3\x97", | ||
| 246 | "\xc3\x98", | ||
| 247 | "\xc3\x99", | ||
| 248 | "\xc3\x9a", | ||
| 249 | "\xc3\x9b", | ||
| 250 | "\xc3\x9c", | ||
| 251 | "\xc3\x9d", | ||
| 252 | "\xc3\x9e", | ||
| 253 | "\xc3\x9f", | ||
| 254 | "\xc3\xa0", | ||
| 255 | "\xc3\xa1", | ||
| 256 | "\xc3\xa2", | ||
| 257 | "\xc3\xa3", | ||
| 258 | "\xc3\xa4", | ||
| 259 | "\xc3\xa5", | ||
| 260 | "\xc3\xa6", | ||
| 261 | "\xc3\xa7", | ||
| 262 | "\xc3\xa8", | ||
| 263 | "\xc3\xa9", | ||
| 264 | "\xc3\xaa", | ||
| 265 | "\xc3\xab", | ||
| 266 | "\xc3\xac", | ||
| 267 | "\xc3\xad", | ||
| 268 | "\xc3\xae", | ||
| 269 | "\xc3\xaf", | ||
| 270 | "\xc3\xb0", | ||
| 271 | "\xc3\xb1", | ||
| 272 | "\xc3\xb2", | ||
| 273 | "\xc3\xb3", | ||
| 274 | "\xc3\xb4", | ||
| 275 | "\xc3\xb5", | ||
| 276 | "\xc3\xb6", | ||
| 277 | "\xc3\xb7", | ||
| 278 | "\xc3\xb8", | ||
| 279 | "\xc3\xb9", | ||
| 280 | "\xc3\xba", | ||
| 281 | "\xc3\xbb", | ||
| 282 | "\xc3\xbc", | ||
| 283 | "\xc3\xbd", | ||
| 284 | "\xc3\xbe", | ||
| 285 | "\xc3\xbf", | ||
| 286 | ]; | ||
| 287 | |||
| 288 | sub _recode | ||
| 289 | { | ||
| 290 | if ($_[0]->{_from} eq 'INTERNAL') { | ||
| 291 | # FIXME: Maybe the lookup is cheaper than the call to chr(). | ||
| 292 | $_[1] = join '', | ||
| 293 | map $_ > 255 ? "\x3f" : chr $_, | ||
| 294 | @{$_[1]}; | ||
| 295 | } elsif ($_[0]->{_to} eq 'UTF-8') { | ||
| 296 | $_[1] = join '', map TO_UTF8->[$_], unpack 'C*', $_[1]; | ||
| 297 | } else { | ||
| 298 | $_[1] = [ unpack 'C*', $_[1] ]; | ||
| 299 | } | ||
| 300 | |||
| 301 | return 1; | ||
| 302 | } | ||
| 303 | |||
| 304 | 1; | ||
| 305 | |||
| 306 | __END__ |