Differences From Artifact [101fcea2a5]:
- File tests/OFStringTests.m — part of check-in [02ca89285f] at 2013-01-07 13:35:12 on branch trunk — Improve API for UTF-16 strings. (user: js, size: 22745) [annotate] [blame] [check-ins using]
To Artifact [7f9159fd57]:
- File
tests/OFStringTests.m
— part of check-in
[9d3cd5e5fe]
at
2013-01-07 22:07:58
on branch trunk
— OFString: Zero-terminate UTF-16 strings.
This partly reverts e8502c7.
The rationale behind this is that, on some OSes, native APIs (on e.g.
Windows) take UTF-16 strings that are zero-terminated.However, forcing zero-termination for every string so that -[characters]
returns a zero-terminated UTF-32 string does not make sense. Therefore,
in the future, -[UTF32String] will be added, which will include
zero-termination. OFString subclasses can then just return their
internal representation if it includes a terminating zero or create a
copy that has a terminating zero if not. (user: js, size: 22619) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
43 44 45 46 47 48 49 | 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0x1F03A }; static of_unichar_t sucstr[] = { 0xFFFE0000, 0x66000000, 0xF6000000, 0xF6000000, 0x62000000, 0xE4000000, 0x72000000, 0x3AF00100 }; static uint16_t utf16str[] = { | | | > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0x1F03A }; static of_unichar_t sucstr[] = { 0xFFFE0000, 0x66000000, 0xF6000000, 0xF6000000, 0x62000000, 0xE4000000, 0x72000000, 0x3AF00100 }; static uint16_t utf16str[] = { 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0xD83C, 0xDC3A, 0 }; static uint16_t sutf16str[] = { 0xFFFE, 0x6600, 0xF600, 0xF600, 0x6200, 0xE400, 0x7200, 0x3CD8, 0x3ADC, 0 }; @interface EntityHandler: OFObject <OFStringXMLUnescapingDelegate> @end @implementation EntityHandler - (OFString*)string: (OFString*)string |
︙ | ︙ | |||
162 163 164 165 166 167 168 | sizeof(*ucstr)]) && [is isEqual: @"fööbär🀺"] && (is = [OFString stringWithCharacters: sucstr length: sizeof(sucstr) / sizeof(*sucstr)]) && [is isEqual: @"fööbär🀺"]) | | | < < | < < | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | sizeof(*ucstr)]) && [is isEqual: @"fööbär🀺"] && (is = [OFString stringWithCharacters: sucstr length: sizeof(sucstr) / sizeof(*sucstr)]) && [is isEqual: @"fööbär🀺"]) TEST(@"+[stringWithUTF16String:]", (is = [OFString stringWithUTF16String: utf16str]) && [is isEqual: @"fööbär🀺"] && (is = [OFString stringWithUTF16String: sutf16str]) && [is isEqual: @"fööbär🀺"]) TEST(@"+[stringWithContentsOfFile:encoding]", (is = [OFString stringWithContentsOfFile: @"testfile.txt" encoding: OF_STRING_ENCODING_ISO_8859_1]) && [is isEqual: @"testäöü"]) |
︙ | ︙ |