ObjFW  Diff

Differences From Artifact [7a39667e23]:

To Artifact [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