Overview
Comment: | Add Windows-1251 encoding |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0f88ccfb04c05c84ea38f1c27e179195 |
User & Date: | js on 2017-01-11 04:22:31 |
Other Links: | manifest | tags |
Context
2017-01-11
| ||
04:33 | Reduce code duplication check-in: 44ea4f9322 user: js tags: trunk | |
04:22 | Add Windows-1251 encoding check-in: 0f88ccfb04 user: js tags: trunk | |
03:49 | Use U+FFFF for invalid characters check-in: a9f85ba3b1 user: js tags: trunk | |
Changes
Modified ObjFW.xcodeproj/project.pbxproj from [07fc46776a] to [52a6ce359d].
︙ | |||
958 959 960 961 962 963 964 965 966 967 968 969 970 971 | 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 | + + | 4BF33B0C133807A20059CEF7 /* OFThreadTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF67B1235358D0076B512 /* OFThreadTests.m */; }; 4BF33B0D133807A20059CEF7 /* OFURLTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF0749512DFAFCA00A4ADD1 /* OFURLTests.m */; }; 4BF33B0E133807A20059CEF7 /* OFXMLElementBuilderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF67C1235358D0076B512 /* OFXMLElementBuilderTests.m */; }; 4BF33B10133807A20059CEF7 /* OFXMLParserTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF67E1235358D0076B512 /* OFXMLParserTests.m */; }; 4BF33B12133807A20059CEF7 /* TestsAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF6811235358D0076B512 /* TestsAppDelegate.m */; }; 4BF33B4713380CE20059CEF7 /* testfile.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4BF33B4313380CD40059CEF7 /* testfile.txt */; }; 4BF33B4813380D2D0059CEF7 /* testfile.bin in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4BF33B4213380CD40059CEF7 /* testfile.bin */; }; 4BF3A2291E25EA48002EA46F /* windows_1251.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF3A2281E25EA48002EA46F /* windows_1251.m */; }; 4BF3A22A1E25EA48002EA46F /* windows_1251.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF3A2281E25EA48002EA46F /* windows_1251.m */; }; 4BF48CE118A95F83000E8D04 /* OFBigDataArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF48CDF18A95F83000E8D04 /* OFBigDataArray.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BF48CE218A95F83000E8D04 /* OFBigDataArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF48CE018A95F83000E8D04 /* OFBigDataArray.m */; }; 4BF69CE61BD44F8B00DFFC1B /* platform.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF69CE51BD44F8B00DFFC1B /* platform.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BFF3714177E17C100192782 /* OFRemoveItemFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BFF3710177E17C100192782 /* OFRemoveItemFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BFF3715177E17C100192782 /* OFRemoveItemFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BFF3711177E17C100192782 /* OFRemoveItemFailedException.m */; }; /* End PBXBuildFile section */ |
︙ | |||
1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 | 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 | + | 4BF1BCCC11C9663F0025511F /* OFString+XMLUnescaping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFString+XMLUnescaping.h"; path = "src/OFString+XMLUnescaping.h"; sourceTree = "<group>"; }; 4BF1BCCD11C9663F0025511F /* OFString+XMLUnescaping.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFString+XMLUnescaping.m"; path = "src/OFString+XMLUnescaping.m"; sourceTree = "<group>"; }; 4BF1BCCE11C9663F0025511F /* OFXMLAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFXMLAttribute.h; path = src/OFXMLAttribute.h; sourceTree = "<group>"; }; 4BF1BCCF11C9663F0025511F /* OFXMLAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFXMLAttribute.m; path = src/OFXMLAttribute.m; sourceTree = "<group>"; }; 4BF33AF0133807310059CEF7 /* Tests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Tests; sourceTree = BUILT_PRODUCTS_DIR; }; 4BF33B4213380CD40059CEF7 /* testfile.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = testfile.bin; path = tests/testfile.bin; sourceTree = "<group>"; }; 4BF33B4313380CD40059CEF7 /* testfile.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = testfile.txt; path = tests/testfile.txt; sourceTree = "<group>"; }; 4BF3A2281E25EA48002EA46F /* windows_1251.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = windows_1251.m; path = src/windows_1251.m; sourceTree = "<group>"; }; 4BF48CDF18A95F83000E8D04 /* OFBigDataArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBigDataArray.h; path = src/OFBigDataArray.h; sourceTree = "<group>"; }; 4BF48CE018A95F83000E8D04 /* OFBigDataArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBigDataArray.m; path = src/OFBigDataArray.m; sourceTree = "<group>"; }; 4BF69CE51BD44F8B00DFFC1B /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = platform.h; path = src/platform.h; sourceTree = "<group>"; }; 4BFBDD1610A0724800051AFB /* unicode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = unicode.m; path = src/unicode.m; sourceTree = "<group>"; }; 4BFF3710177E17C100192782 /* OFRemoveItemFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFRemoveItemFailedException.h; path = src/exceptions/OFRemoveItemFailedException.h; sourceTree = "<group>"; }; 4BFF3711177E17C100192782 /* OFRemoveItemFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRemoveItemFailedException.m; path = src/exceptions/OFRemoveItemFailedException.m; sourceTree = "<group>"; }; /* End PBXFileReference section */ |
︙ | |||
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 | 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 | + | 4B40EC1A189FE2650031E19E /* socket.m */, 4B7DD58118942FE200990FD6 /* socket_helpers.h */, 4B67998B1099E7C50041064A /* threading.h */, 4B3379CE1979326A0088E97E /* threading.m */, 4BABC29A197A8212006A93BD /* threading_pthread.m */, 4B67998C1099E7C50041064A /* unicode.h */, 4BFBDD1610A0724800051AFB /* unicode.m */, 4BF3A2281E25EA48002EA46F /* windows_1251.m */, 4B6AF97210A8D42E0003FB0A /* windows_1252.m */, ); name = ObjFW; sourceTree = "<group>"; }; 4B6EF66D123535480076B512 /* Tests */ = { isa = PBXGroup; |
︙ | |||
3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 | 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 | + | 4B2C218F1DA292BE00735907 /* of_strptime.m in Sources */, 4B2C21901DA292BE00735907 /* pbkdf2.m in Sources */, 4B2C21911DA292BE00735907 /* resolver.m in Sources */, 4B2C21921DA292BE00735907 /* scrypt.m in Sources */, 4B2C21931DA292BE00735907 /* socket.m in Sources */, 4B2C21941DA292BE00735907 /* threading.m in Sources */, 4B2C21961DA292BE00735907 /* unicode.m in Sources */, 4BF3A22A1E25EA48002EA46F /* windows_1251.m in Sources */, 4B2C21971DA292BE00735907 /* windows_1252.m in Sources */, 4B2C21981DA292BE00735907 /* OFAcceptFailedException.m in Sources */, 4B2C21991DA292BE00735907 /* OFObject+KeyValueCoding.m in Sources */, 4B2C219A1DA292BE00735907 /* OFAddressTranslationFailedException.m in Sources */, 4B2C219B1DA292BE00735907 /* OFAllocFailedException.m in Sources */, 4B2C219C1DA292BE00735907 /* OFAlreadyConnectedException.m in Sources */, 4B2C219D1DA292BE00735907 /* OFBindFailedException.m in Sources */, |
︙ | |||
3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 | 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 | + | 4BA355BA14879BDD00442EF4 /* of_strptime.m in Sources */, 4BD306351D46CEE300E2F372 /* pbkdf2.m in Sources */, 4B7769EE1895C07D00D12284 /* resolver.m in Sources */, 4B6994481D47FB1A007F34DF /* scrypt.m in Sources */, 4B40EC1B189FE2650031E19E /* socket.m in Sources */, 4B3379CF1979326A0088E97E /* threading.m in Sources */, 4B3D23B91337FC0D00DD29B8 /* unicode.m in Sources */, 4BF3A2291E25EA48002EA46F /* windows_1251.m in Sources */, 4B3D23BA1337FC0D00DD29B8 /* windows_1252.m in Sources */, 4B90B79F133AD87D00BD33CB /* OFAcceptFailedException.m in Sources */, 4BC176311D04963000C32718 /* OFObject+KeyValueCoding.m in Sources */, 4B90B7A1133AD87D00BD33CB /* OFAddressTranslationFailedException.m in Sources */, 4B17FF80133A2D17003E6DCD /* OFAllocFailedException.m in Sources */, 4B90B78E133AD46700BD33CB /* OFAlreadyConnectedException.m in Sources */, 4B90B7A3133AD87D00BD33CB /* OFBindFailedException.m in Sources */, |
︙ |
Modified src/Makefile from [374f171e27] to [1e97ec4295].
︙ | |||
156 157 158 159 160 161 162 163 164 165 166 167 168 169 | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | + | codepage_437.m \ codepage_850.m \ ${FOUNDATION_COMPAT_M} \ ${INSTANCE_M} \ iso_8859_15.m \ mac_roman.m \ ${UNICODE_M} \ windows_1251.m \ windows_1252.m SRCS_FILES += OFSettings_INIFile.m SRCS_SOCKETS += ${OFKERNELEVENTOBSERVER_EPOLL_M} \ ${OFKERNELEVENTOBSERVER_KQUEUE_M} \ ${OFKERNELEVENTOBSERVER_POLL_M} \ ${OFKERNELEVENTOBSERVER_SELECT_M} \ OFTCPSocket+SOCKS5.m |
︙ |
Modified src/OFHTTPResponse.m from [7bcf69b951] to [53242c671e].
︙ | |||
109 110 111 112 113 114 115 | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | - + - + + + - + - + | if (encoding == OF_STRING_ENCODING_AUTODETECT && (contentType = [_headers objectForKey: @"Content-Type"]) != nil) { contentType = [contentType lowercaseString]; if ([contentType hasSuffix: @"charset=utf-8"]) encoding = OF_STRING_ENCODING_UTF_8; |
︙ |
Modified src/OFLocalization.m from [5e507e5b86] to [9170e13ef8].
︙ | |||
105 106 107 108 109 110 111 112 113 114 115 116 117 118 | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | + + | else if (strcmp(tmp, "iso8859-1") == 0 || strcmp(tmp, "iso-8859-1") == 0) _encoding = OF_STRING_ENCODING_ISO_8859_1; else if (strcmp(tmp, "iso8859-15") == 0 || strcmp(tmp, "iso-8859-15") == 0) _encoding = OF_STRING_ENCODING_ISO_8859_15; /* Windows uses a codepage */ else if (strcmp(tmp, "1251") == 0) _encoding = OF_STRING_ENCODING_WINDOWS_1251; else if (strcmp(tmp, "1252") == 0) _encoding = OF_STRING_ENCODING_WINDOWS_1252; } /* Territory */ if ((tmp = strrchr(locale, '_')) != NULL) { *tmp++ = '\0'; |
︙ |
Modified src/OFString.h from [78eb3b06a4] to [9936d08fa6].
︙ | |||
56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | + + | OF_STRING_ENCODING_UTF_8, /*! ASCII */ OF_STRING_ENCODING_ASCII, /*! ISO 8859-1 */ OF_STRING_ENCODING_ISO_8859_1, /*! ISO 8859-15 */ OF_STRING_ENCODING_ISO_8859_15, /*! Windows-1251 */ OF_STRING_ENCODING_WINDOWS_1251, /*! Windows-1252 */ OF_STRING_ENCODING_WINDOWS_1252, /*! Codepage 437 */ OF_STRING_ENCODING_CODEPAGE_437, /*! Codepage 850 */ OF_STRING_ENCODING_CODEPAGE_850, /*! Mac OS Roman */ |
︙ |
Modified src/OFString.m from [a66e682c7d] to [c458b1a41f].
︙ | |||
87 88 89 90 91 92 93 94 95 96 97 98 99 100 | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | + + | lossy: (bool)lossy; - (OFString*)OF_JSONRepresentationWithOptions: (int)options depth: (size_t)depth; @end extern bool of_unicode_to_iso_8859_15(const of_unichar_t*, unsigned char*, size_t, bool); extern bool of_unicode_to_windows_1251(const of_unichar_t*, unsigned char*, size_t, bool); extern bool of_unicode_to_windows_1252(const of_unichar_t*, unsigned char*, size_t, bool); extern bool of_unicode_to_codepage_437(const of_unichar_t*, unsigned char*, size_t, bool); extern bool of_unicode_to_codepage_850(const of_unichar_t*, unsigned char*, size_t, bool); extern bool of_unicode_to_mac_roman(const of_unichar_t*, unsigned char*, |
︙ | |||
949 950 951 952 953 954 955 | 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 | - + - + + - + + + + + - + | if (encoding == OF_STRING_ENCODING_AUTODETECT && (contentType = [headers objectForKey: @"Content-Type"]) != nil) { contentType = [contentType lowercaseString]; if ([contentType hasSuffix: @"charset=utf-8"]) encoding = OF_STRING_ENCODING_UTF_8; |
︙ | |||
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 | 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 | + + + + + + + + + + + | if (!of_unicode_to_iso_8859_15(characters, (unsigned char*)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; return length; case OF_STRING_ENCODING_WINDOWS_1251: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; if (!of_unicode_to_windows_1251(characters, (unsigned char*)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; return length; case OF_STRING_ENCODING_WINDOWS_1252: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; if (!of_unicode_to_windows_1252(characters, (unsigned char*)cString, length, lossy)) |
︙ | |||
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 | 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 | + | /* We don't care, as we only tried to make it smaller */ } break; case OF_STRING_ENCODING_ASCII: case OF_STRING_ENCODING_ISO_8859_1: 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_MAC_ROMAN: cString = [object allocMemoryWithSize: length + 1]; [self OF_getCString: cString |
︙ | |||
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 | 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 | + | UTF8StringLength += len; } return UTF8StringLength; case OF_STRING_ENCODING_ASCII: case OF_STRING_ENCODING_ISO_8859_1: 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_MAC_ROMAN: return [self length]; default: @throw [OFInvalidEncodingException exception]; |
︙ |
Modified src/OFString_UTF8.m from [38f6296657] to [fe504fcb59].
︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | + | #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "of_asprintf.h" #import "unicode.h" 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_mac_roman[128]; static inline int memcasecmp(const char *first, const char *second, size_t length) |
︙ | |||
286 287 288 289 290 291 292 293 294 295 296 297 298 299 | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | + + + | return self; } switch (encoding) { case OF_STRING_ENCODING_ISO_8859_15: table = of_iso_8859_15; break; case OF_STRING_ENCODING_WINDOWS_1251: table = of_windows_1251; break; case OF_STRING_ENCODING_WINDOWS_1252: table = of_windows_1252; break; case OF_STRING_ENCODING_CODEPAGE_437: table = of_codepage_437; break; |
︙ |
Modified src/OFXMLParser.m from [ab4dd1b1f9] to [d432f9b587].
︙ | |||
468 469 470 471 472 473 474 475 476 477 478 479 480 481 | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | + + + | _encoding = OF_STRING_ENCODING_UTF_8; else if ([value isEqual: @"iso-8859-1"]) _encoding = OF_STRING_ENCODING_ISO_8859_1; else if ([value isEqual: @"iso-8859-15"]) _encoding = OF_STRING_ENCODING_ISO_8859_15; else if ([value isEqual: @"windows-1251"]) _encoding = OF_STRING_ENCODING_WINDOWS_1251; else if ([value isEqual: @"windows-1252"]) _encoding = OF_STRING_ENCODING_WINDOWS_1252; else if ([value isEqual: @"macintosh"]) _encoding = OF_STRING_ENCODING_MAC_ROMAN; else |
︙ |
Added src/windows_1251.m version [6ea0727109].