Overview
Comment: | Add support for C strings encoded in Windows-1252. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e04c35978033770ec23ce55fb4bb31d2 |
User & Date: | js on 2009-07-20 23:20:26 |
Other Links: | manifest | tags |
Context
2009-07-21
| ||
16:08 | Fix wrong order of retain / release. check-in: a7b6d69e14 user: js tags: trunk | |
2009-07-20
| ||
23:20 | Add support for C strings encoded in Windows-1252. check-in: e04c359780 user: js tags: trunk | |
18:39 | Add support for C strings encoded in ISO 8859-15. check-in: 0ea758cd9c user: js tags: trunk | |
Changes
Modified src/OFString.h from [d669b9c0c5] to [070cca9ea4].
︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | + | #import "OFObject.h" #import "OFArray.h" enum of_string_encoding { OF_STRING_ENCODING_UTF_8, OF_STRING_ENCODING_ISO_8859_1, OF_STRING_ENCODING_ISO_8859_15, OF_STRING_ENCODING_WINDOWS_1252 }; extern int of_string_check_utf8(const char*, size_t); extern size_t of_string_unicode_to_utf8(uint32_t, char*); /** * A class for managing strings. |
︙ |
Modified src/OFString.m from [472df8f045] to [7a4ce00abf].
︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | + | #import "OFAutoreleasePool.h" #import "OFExceptions.h" #import "OFMacros.h" #import "asprintf.h" #import "encodings/iso_8859_15.h" #import "encodings/windows_1252.h" /* References for static linking */ void _references_to_categories_of_OFString() { _OFHashing_reference = 1; _OFURLEncoding_reference = 1; _OFXMLElement_reference = 1; |
︙ | |||
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 | 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 | + + + + + + + + + + + + + + + + + + | memcpy(string, str, length); string[length] = 0; break; case OF_STRING_ENCODING_ISO_8859_1: case OF_STRING_ENCODING_ISO_8859_15: case OF_STRING_ENCODING_WINDOWS_1252: for (i = j = 0; i < len; i++) { if ((uint8_t)str[i] < 0x80) string[j++] = str[i]; else { char buf[4]; uint32_t chr; size_t chr_bytes; switch (encoding) { case OF_STRING_ENCODING_ISO_8859_1: chr = (uint8_t)str[i]; break; case OF_STRING_ENCODING_ISO_8859_15: chr = iso_8859_15_to_unicode[ (uint8_t)str[i]]; break; case OF_STRING_ENCODING_WINDOWS_1252: chr = windows_1252_to_unicode[ (uint8_t)str[i]]; break; default: /* * We can't use [super dealloc] on OS X * here. Compiler bug? Anyway, * [self dealloc] will do here as we * don't reimplement dealloc. */ c = isa; [self dealloc]; @throw [OFInvalidEncodingException newWithClass: c]; } if (chr == 0xFFFD) { /* * We can't use [super dealloc] on OS X * here. Compiler bug? Anyway, * [self dealloc] will do here as we * don't reimplement dealloc. */ c = isa; |
︙ |
Modified src/encodings/iso_8859_15.h from [2ef850307a] to [fe0487da8d].
|
Added src/encodings/windows_1252.h version [b20dd0f9cd].
|
Modified tests/OFString/OFString.m from [74ea65afd6] to [2fbf2def3c].
︙ | |||
20 21 22 23 24 25 26 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | - + | #ifndef _WIN32 #define ZD "%zd" #else #define ZD "%u" #endif |
︙ | |||
111 112 113 114 115 116 117 | 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 | - + + + + + + + | CHECK_EXCEPT(s1 = [OFString stringWithCString: "\xF0\x80\x80\xC0"], OFInvalidEncodingException) s1 = [OFMutableString stringWithCString: "äöü€𝄞"]; CHECK([[s1 reverse] isEqual: @"𝄞€üöä"]) [s1 dealloc]; |
︙ |