Overview
Comment: | Add KOI8-R encoding |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
59348cd51da05695821b9cc91e3c3853 |
User & Date: | js on 2017-02-05 01:31:59 |
Other Links: | manifest | tags |
Context
2017-02-05
| ||
21:22 | Add KOI8-U encoding check-in: 2c489201b7 user: js tags: trunk | |
01:31 | Add KOI8-R encoding check-in: 59348cd51d user: js tags: trunk | |
2017-02-04
| ||
21:37 | OFRunLoop: Refactor read queue handling check-in: 6ae356af85 user: js tags: trunk | |
Changes
Modified configure.ac from [bab9e68aa8] to [8493d1aa1e].
︙ | ︙ | |||
610 611 612 613 614 615 616 617 618 619 620 621 622 623 | ]) ]) ENCODING_FLAG(codepage-437, codepage_437, [Codepage 437], HAVE_CODEPAGE_437) ENCODING_FLAG(codepage-850, codepage_850, [Codepage 850], HAVE_CODEPAGE_850) ENCODING_FLAG(codepage-858, codepage_858, [Codepage 858], HAVE_CODEPAGE_858) ENCODING_FLAG(iso-8859-2, iso_8859_2, [ISO 8859-2], HAVE_ISO_8859_2) ENCODING_FLAG(iso-8859-15, iso_8859_15, [ISO 8859-15], HAVE_ISO_8859_15) ENCODING_FLAG(mac-roman, mac_roman, [Mac Roman encoding], HAVE_MAC_ROMAN) ENCODING_FLAG(windows-1251, windows_1251, [Windows-1251], HAVE_WINDOWS_1251) ENCODING_FLAG(windows-1252, windows_1252, [Windows-1252], HAVE_WINDOWS_1252) AC_SUBST(ENCODINGS_SRCS) AS_IF([test x"$ENCODINGS_SRCS" != x""], [ AC_SUBST(ENCODINGS, "encodings") | > | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | ]) ]) ENCODING_FLAG(codepage-437, codepage_437, [Codepage 437], HAVE_CODEPAGE_437) ENCODING_FLAG(codepage-850, codepage_850, [Codepage 850], HAVE_CODEPAGE_850) ENCODING_FLAG(codepage-858, codepage_858, [Codepage 858], HAVE_CODEPAGE_858) ENCODING_FLAG(iso-8859-2, iso_8859_2, [ISO 8859-2], HAVE_ISO_8859_2) ENCODING_FLAG(iso-8859-15, iso_8859_15, [ISO 8859-15], HAVE_ISO_8859_15) ENCODING_FLAG(koi8-r, koi8_r, [KOI8-R], HAVE_KOI8_R) ENCODING_FLAG(mac-roman, mac_roman, [Mac Roman encoding], HAVE_MAC_ROMAN) ENCODING_FLAG(windows-1251, windows_1251, [Windows-1251], HAVE_WINDOWS_1251) ENCODING_FLAG(windows-1252, windows_1252, [Windows-1252], HAVE_WINDOWS_1252) AC_SUBST(ENCODINGS_SRCS) AS_IF([test x"$ENCODINGS_SRCS" != x""], [ AC_SUBST(ENCODINGS, "encodings") |
︙ | ︙ |
Modified src/OFString.h from [f2b1c1c2e0] to [7404ad4f5f].
︙ | ︙ | |||
70 71 72 73 74 75 76 77 78 79 80 81 82 83 | OF_STRING_ENCODING_CODEPAGE_437, /*! Codepage 850 */ OF_STRING_ENCODING_CODEPAGE_850, /*! Codepage 858 */ OF_STRING_ENCODING_CODEPAGE_858, /*! Mac OS Roman */ OF_STRING_ENCODING_MAC_ROMAN, /*! Try to automatically detect the encoding */ OF_STRING_ENCODING_AUTODETECT = 0xFF } of_string_encoding_t; enum { OF_STRING_SEARCH_BACKWARDS = 1, OF_STRING_SKIP_EMPTY = 2 | > > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | OF_STRING_ENCODING_CODEPAGE_437, /*! Codepage 850 */ OF_STRING_ENCODING_CODEPAGE_850, /*! Codepage 858 */ OF_STRING_ENCODING_CODEPAGE_858, /*! Mac OS Roman */ OF_STRING_ENCODING_MAC_ROMAN, /*! KOI8-R */ OF_STRING_ENCODING_KOI8_R, /*! Try to automatically detect the encoding */ OF_STRING_ENCODING_AUTODETECT = 0xFF } of_string_encoding_t; enum { OF_STRING_SEARCH_BACKWARDS = 1, OF_STRING_SKIP_EMPTY = 2 |
︙ | ︙ |
Modified src/OFString.m from [25043e1af3] to [5396444804].
︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 113 114 | size_t, bool); extern bool of_unicode_to_codepage_850(const of_unichar_t*, unsigned char*, size_t, bool); extern bool of_unicode_to_codepage_858(const of_unichar_t*, unsigned char*, size_t, bool); extern bool of_unicode_to_mac_roman(const of_unichar_t*, unsigned char*, size_t, bool); /* References for static linking */ void _references_to_categories_of_OFString(void) { _OFString_CryptoHashing_reference = 1; _OFString_JSONValue_reference = 1; | > > | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | size_t, bool); extern bool of_unicode_to_codepage_850(const of_unichar_t*, unsigned char*, size_t, bool); extern bool of_unicode_to_codepage_858(const of_unichar_t*, unsigned char*, size_t, bool); extern bool of_unicode_to_mac_roman(const of_unichar_t*, unsigned char*, size_t, bool); extern bool of_unicode_to_koi8_r(const of_unichar_t*, unsigned char*, size_t, bool); /* References for static linking */ void _references_to_categories_of_OFString(void) { _OFString_CryptoHashing_reference = 1; _OFString_JSONValue_reference = 1; |
︙ | ︙ | |||
160 161 162 163 164 165 166 167 168 169 170 171 172 173 | [string isEqual: @"ibm850"] || [string isEqual: @"850"]) encoding = OF_STRING_ENCODING_CODEPAGE_850; else if ([string isEqual: @"cp858"] || [string isEqual: @"cp-858"] || [string isEqual: @"ibm858"] || [string isEqual: @"858"]) encoding = OF_STRING_ENCODING_CODEPAGE_858; else if ([string isEqual: @"macintosh"] || [string isEqual: @"mac"]) encoding = OF_STRING_ENCODING_MAC_ROMAN; else @throw [OFInvalidEncodingException exception]; objc_autoreleasePoolPop(pool); return encoding; } | > > | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | [string isEqual: @"ibm850"] || [string isEqual: @"850"]) encoding = OF_STRING_ENCODING_CODEPAGE_850; else if ([string isEqual: @"cp858"] || [string isEqual: @"cp-858"] || [string isEqual: @"ibm858"] || [string isEqual: @"858"]) encoding = OF_STRING_ENCODING_CODEPAGE_858; else if ([string isEqual: @"macintosh"] || [string isEqual: @"mac"]) encoding = OF_STRING_ENCODING_MAC_ROMAN; else if ([string isEqual: @"koi8-r"]) encoding = OF_STRING_ENCODING_KOI8_R; else @throw [OFInvalidEncodingException exception]; objc_autoreleasePoolPop(pool); return encoding; } |
︙ | ︙ | |||
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 | (unsigned char*)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; return length; #endif default: @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; } } - (size_t)getCString: (char*)cString | > > > > > > > > > > > > > | 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 | (unsigned char*)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; return length; #endif #ifdef HAVE_KOI8_R case OF_STRING_ENCODING_KOI8_R: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; if (!of_unicode_to_koi8_r(characters, (unsigned char*)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; return length; #endif default: @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; } } - (size_t)getCString: (char*)cString |
︙ | ︙ | |||
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 | case OF_STRING_ENCODING_ISO_8859_15: case OF_STRING_ENCODING_WINDOWS_1251: case OF_STRING_ENCODING_WINDOWS_1252: case OF_STRING_ENCODING_CODEPAGE_437: case OF_STRING_ENCODING_CODEPAGE_850: case OF_STRING_ENCODING_CODEPAGE_858: case OF_STRING_ENCODING_MAC_ROMAN: cString = [object allocMemoryWithSize: length + 1]; [self OF_getCString: cString maxLength: length + 1 encoding: encoding lossy: lossy]; | > | 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 | case OF_STRING_ENCODING_ISO_8859_15: case OF_STRING_ENCODING_WINDOWS_1251: case OF_STRING_ENCODING_WINDOWS_1252: case OF_STRING_ENCODING_CODEPAGE_437: case OF_STRING_ENCODING_CODEPAGE_850: case OF_STRING_ENCODING_CODEPAGE_858: case OF_STRING_ENCODING_MAC_ROMAN: case OF_STRING_ENCODING_KOI8_R: cString = [object allocMemoryWithSize: length + 1]; [self OF_getCString: cString maxLength: length + 1 encoding: encoding lossy: lossy]; |
︙ | ︙ | |||
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 | case OF_STRING_ENCODING_ISO_8859_15: case OF_STRING_ENCODING_WINDOWS_1251: case OF_STRING_ENCODING_WINDOWS_1252: case OF_STRING_ENCODING_CODEPAGE_437: case OF_STRING_ENCODING_CODEPAGE_850: case OF_STRING_ENCODING_CODEPAGE_858: case OF_STRING_ENCODING_MAC_ROMAN: return [self length]; default: @throw [OFInvalidEncodingException exception]; } } - (size_t)UTF8StringLength | > | 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 | case OF_STRING_ENCODING_ISO_8859_15: case OF_STRING_ENCODING_WINDOWS_1251: case OF_STRING_ENCODING_WINDOWS_1252: case OF_STRING_ENCODING_CODEPAGE_437: case OF_STRING_ENCODING_CODEPAGE_850: case OF_STRING_ENCODING_CODEPAGE_858: case OF_STRING_ENCODING_MAC_ROMAN: case OF_STRING_ENCODING_KOI8_R: return [self length]; default: @throw [OFInvalidEncodingException exception]; } } - (size_t)UTF8StringLength |
︙ | ︙ |
Modified src/OFString_UTF8.m from [652cb8ee2f] to [7036f0659c].
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 51 52 53 54 55 | extern const of_char16_t of_iso_8859_15[128]; extern const of_char16_t of_windows_1251[128]; extern const of_char16_t of_windows_1252[128]; extern const of_char16_t of_codepage_437[128]; extern const of_char16_t of_codepage_850[128]; extern const of_char16_t of_codepage_858[128]; extern const of_char16_t of_mac_roman[128]; static inline int memcasecmp(const char *first, const char *second, size_t length) { for (size_t i = 0; i < length; i++) { unsigned char f = first[i]; unsigned char s = second[i]; | > | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | extern const of_char16_t of_iso_8859_15[128]; extern const of_char16_t of_windows_1251[128]; extern const of_char16_t of_windows_1252[128]; extern const of_char16_t of_codepage_437[128]; extern const of_char16_t of_codepage_850[128]; extern const of_char16_t of_codepage_858[128]; extern const of_char16_t of_mac_roman[128]; extern const of_char16_t of_koi8_r[128]; static inline int memcasecmp(const char *first, const char *second, size_t length) { for (size_t i = 0; i < length; i++) { unsigned char f = first[i]; unsigned char s = second[i]; |
︙ | ︙ | |||
326 327 328 329 330 331 332 333 334 335 336 337 338 339 | table = of_codepage_858; break; #endif #ifdef HAVE_MAC_ROMAN case OF_STRING_ENCODING_MAC_ROMAN: table = of_mac_roman; break; #endif default: @throw [OFInvalidEncodingException exception]; } j = 0; for (size_t i = 0; i < cStringLength; i++) { | > > > > > | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | table = of_codepage_858; break; #endif #ifdef HAVE_MAC_ROMAN case OF_STRING_ENCODING_MAC_ROMAN: table = of_mac_roman; break; #endif #ifdef HAVE_KOI8_R case OF_STRING_ENCODING_KOI8_R: table = of_koi8_r; break; #endif default: @throw [OFInvalidEncodingException exception]; } j = 0; for (size_t i = 0; i < cStringLength; i++) { |
︙ | ︙ |
Added src/encodings/koi8_r.m version [7def00b22a].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFString.h" const of_char16_t of_koi8_r[128] = { 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590, 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248, 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7, 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E, 0x255F, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x00A9, 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A, 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A }; bool of_unicode_to_koi8_r(const of_unichar_t *input, unsigned char *output, size_t length, bool lossy) { for (size_t i = 0; i < length; i++) { of_unichar_t c = input[i]; if OF_UNLIKELY (c > 0x7F) { if OF_UNLIKELY (c > 0xFFFF) { if (lossy) { output[i] = '?'; continue; } else return false; } if OF_LIKELY (c >= 0x438 && c <= 0x43F) output[i] = 0xC9 + (c - 0x438); else if OF_LIKELY (c >= 0x418 && c <= 0x41F) output[i] = 0xE9 + (c - 0x418); else if OF_UNLIKELY (c >= 0x2553 && c <= 0x2561) output[i] = 0xA4 + (c - 0x2553); else if OF_UNLIKELY (c >= 0x2562 && c <= 0x256C) output[i] = 0xB4 + (c - 0x2562); else { switch ((of_char16_t)c) { case 0x2500: output[i] = 0x80; break; case 0x2502: output[i] = 0x81; break; case 0x250C: output[i] = 0x82; break; case 0x2510: output[i] = 0x83; break; case 0x2514: output[i] = 0x84; break; case 0x2518: output[i] = 0x85; break; case 0x251C: output[i] = 0x86; break; case 0x2524: output[i] = 0x87; break; case 0x252C: output[i] = 0x88; break; case 0x2534: output[i] = 0x89; break; case 0x253C: output[i] = 0x8A; break; case 0x2580: output[i] = 0x8B; break; case 0x2584: output[i] = 0x8C; break; case 0x2588: output[i] = 0x8D; break; case 0x258C: output[i] = 0x8E; break; case 0x2590: output[i] = 0x8F; break; case 0x2591: output[i] = 0x90; break; case 0x2592: output[i] = 0x91; break; case 0x2593: output[i] = 0x92; break; case 0x2320: output[i] = 0x93; break; case 0x25A0: output[i] = 0x94; break; case 0x2219: output[i] = 0x95; break; case 0x221A: output[i] = 0x96; break; case 0x2248: output[i] = 0x97; break; case 0x2264: output[i] = 0x98; break; case 0x2265: output[i] = 0x99; break; case 0xA0: output[i] = 0x9A; break; case 0x2321: output[i] = 0x9B; break; case 0xB0: output[i] = 0x9C; break; case 0xB2: output[i] = 0x9D; break; case 0xB7: output[i] = 0x9E; break; case 0xF7: output[i] = 0x9F; break; case 0x2550: output[i] = 0xA0; break; case 0x2551: output[i] = 0xA1; break; case 0x2552: output[i] = 0xA2; break; case 0x451: output[i] = 0xA3; break; case 0x401: output[i] = 0xB3; break; case 0xA9: output[i] = 0xBF; break; case 0x44E: output[i] = 0xC0; break; case 0x430: output[i] = 0xC1; break; case 0x431: output[i] = 0xC2; break; case 0x446: output[i] = 0xC3; break; case 0x434: output[i] = 0xC4; break; case 0x435: output[i] = 0xC5; break; case 0x444: output[i] = 0xC6; break; case 0x433: output[i] = 0xC7; break; case 0x445: output[i] = 0xC8; break; case 0x44F: output[i] = 0xD1; break; case 0x440: output[i] = 0xD2; break; case 0x441: output[i] = 0xD3; break; case 0x442: output[i] = 0xD4; break; case 0x443: output[i] = 0xD5; break; case 0x436: output[i] = 0xD6; break; case 0x432: output[i] = 0xD7; break; case 0x44C: output[i] = 0xD8; break; case 0x44B: output[i] = 0xD9; break; case 0x437: output[i] = 0xDA; break; case 0x448: output[i] = 0xDB; break; case 0x44D: output[i] = 0xDC; break; case 0x449: output[i] = 0xDD; break; case 0x447: output[i] = 0xDE; break; case 0x44A: output[i] = 0xDF; break; case 0x42E: output[i] = 0xE0; break; case 0x410: output[i] = 0xE1; break; case 0x411: output[i] = 0xE2; break; case 0x426: output[i] = 0xE3; break; case 0x414: output[i] = 0xE4; break; case 0x415: output[i] = 0xE5; break; case 0x424: output[i] = 0xE6; break; case 0x413: output[i] = 0xE7; break; case 0x425: output[i] = 0xE8; break; case 0x42F: output[i] = 0xF1; break; case 0x420: output[i] = 0xF2; break; case 0x421: output[i] = 0xF3; break; case 0x422: output[i] = 0xF4; break; case 0x423: output[i] = 0xF5; break; case 0x416: output[i] = 0xF6; break; case 0x412: output[i] = 0xF7; break; case 0x42C: output[i] = 0xF8; break; case 0x42B: output[i] = 0xF9; break; case 0x417: output[i] = 0xFA; break; case 0x428: output[i] = 0xFB; break; case 0x42D: output[i] = 0xFC; break; case 0x429: output[i] = 0xFD; break; case 0x427: output[i] = 0xFE; break; case 0x42A: output[i] = 0xFF; break; default: if (lossy) output[i] = '?'; else return false; break; } } } else output[i] = (unsigned char)c; } return true; } |
Modified src/of_strptime.m from [5245738c16] to [9c609e758d].
︙ | ︙ | |||
16 17 18 19 20 21 22 | #include "config.h" #include <string.h> #include <time.h> | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include "config.h" #include <string.h> #include <time.h> #import "macros.h" const char* of_strptime(const char *buffer, const char *format, struct tm *tm, int16_t *tz) { enum { SEARCH_CONVERSION_SPECIFIER, IN_CONVERSION_SPECIFIER |
︙ | ︙ |