ObjFW  Check-in [7920f081ec]

Overview
Comment:Add OF_STRING_ENCODING_ASCII.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7920f081ecaaea798aba2d2339ac80dfd66a06f7a1725a1b886a8c7dcdc7a81f
User & Date: js on 2011-09-12 18:26:56
Other Links: manifest | tags
Context
2011-09-12
18:40
Add OF_STRING_ENCODING_NATIVE. check-in: 96e70bb9c4 user: js tags: trunk
18:26
Add OF_STRING_ENCODING_ASCII. check-in: 7920f081ec user: js tags: trunk
2011-09-11
17:09
Documentation improvements. check-in: 8d554c0421 user: js tags: trunk
Changes

Modified src/OFString.h from [3b28f920b3] to [106ad7b993].

28
29
30
31
32
33
34

35
36
37
38
39
40
41
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42







+







typedef uint32_t of_unichar_t;

/**
 * \brief The encoding of a string.
 */
typedef enum of_string_encoding_t {
	OF_STRING_ENCODING_UTF_8,
	OF_STRING_ENCODING_ASCII,
	OF_STRING_ENCODING_ISO_8859_1,
	OF_STRING_ENCODING_ISO_8859_15,
	OF_STRING_ENCODING_WINDOWS_1252,
	OF_STRING_ENCODING_AUTODETECT = 0xFF
} of_string_encoding_t;

#ifdef __cplusplus

Modified src/OFString.m from [eb163b9c24] to [a0631a1efb].

477
478
479
480
481
482
483
484


485
486
487




488
489
490
491
492
493
494
477
478
479
480
481
482
483

484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499







-
+
+



+
+
+
+








		s = [self allocMemoryWithSize: sizeof(*s)];
		memset(s, 0, sizeof(*s));

		s->cString = [self allocMemoryWithSize: cStringLength + 1];
		s->cStringLength = cStringLength;

		if (encoding == OF_STRING_ENCODING_UTF_8) {
		if (encoding == OF_STRING_ENCODING_UTF_8 ||
		    encoding == OF_STRING_ENCODING_ASCII) {
			switch (of_string_check_utf8(cString, cStringLength,
			    &s->length)) {
			case 1:
				if (encoding == OF_STRING_ENCODING_ASCII)
					@throw [OFInvalidEncodingException
					    newWithClass: isa];

				s->isUTF8 = YES;
				break;
			case -1:
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
			}