ObjFW  Check-in [5eae1c66bc]

Overview
Comment:Two minor changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5eae1c66bc94d2cf2cea416e78f223978635a656da256bec88fedcbe38bde25e
User & Date: js on 2009-07-17 17:17:24
Other Links: manifest | tags
Context
2009-07-17
20:11
Forgot to hg add OFXMLParser test. Fixed. check-in: cb145d6634 user: js tags: trunk
17:17
Two minor changes. check-in: 5eae1c66bc user: js tags: trunk
15:16
Initial OFXMLParser implementation. There's still a LOT missing. check-in: 8f4d7a5b74 user: js tags: trunk
Changes

Modified src/OFString.m from [7a39667e23] to [a8bcd353b2].

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

	return utf8;
}

size_t
of_string_unicode_to_utf8(uint32_t c, char *buf)
{


	if (c < 0x80) {
		buf[0] = c;
		return 1;
	}
	if (c < 0x800) {
		buf[0] = 0xC0 | (c >> 6);
		buf[1] = 0x80 | (c & 0x3F);
		return 2;
	}
	if (c < 0x10000) {
		buf[0] = 0xE0 | (c >> 12);
		buf[1] = 0x80 | (c >> 6 & 0x3F);
		buf[2] = 0x80 | (c & 0x3F);
		return 3;
	}
	if (c < 0x110000) {
		buf[0] = 0xF0 | (c >> 18);
		buf[1] = 0x80 | (c >> 12 & 0x3F);
		buf[2] = 0x80 | (c >> 6 & 0x3F);
		buf[3] = 0x80 | (c & 0x3F);
		return 4;
	}

	return 0;
}

@implementation OFString







>
>

|



|
|



|
|
|



|
|
|
|







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

	return utf8;
}

size_t
of_string_unicode_to_utf8(uint32_t c, char *buf)
{
	size_t i = 0;

	if (c < 0x80) {
		buf[i] = c;
		return 1;
	}
	if (c < 0x800) {
		buf[i++] = 0xC0 | (c >> 6);
		buf[i] = 0x80 | (c & 0x3F);
		return 2;
	}
	if (c < 0x10000) {
		buf[i++] = 0xE0 | (c >> 12);
		buf[i++] = 0x80 | (c >> 6 & 0x3F);
		buf[i] = 0x80 | (c & 0x3F);
		return 3;
	}
	if (c < 0x110000) {
		buf[i++] = 0xF0 | (c >> 18);
		buf[i++] = 0x80 | (c >> 12 & 0x3F);
		buf[i++] = 0x80 | (c >> 6 & 0x3F);
		buf[i] = 0x80 | (c & 0x3F);
		return 4;
	}

	return 0;
}

@implementation OFString

Modified src/OFXMLParser.m from [2e574ba290] to [9cf8e5058f].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

int _OFXMLParser_reference;

static OF_INLINE OFString*
parse_numeric_entity(char *entity, size_t length)
{
	uint32_t c;
	size_t i;
	char buf[4];

	if (length == 1 || *entity != '#')
		return nil;







|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

int _OFXMLParser_reference;

static OF_INLINE OFString*
parse_numeric_entity(const char *entity, size_t length)
{
	uint32_t c;
	size_t i;
	char buf[4];

	if (length == 1 || *entity != '#')
		return nil;