ObjFW  Diff

Differences From Artifact [c51d9e7bc3]:

To Artifact [2bac621bba]:


100
101
102
103
104
105
106





























107
108
109
110
111
112
113
		i += 3;
	}

	madvise((void*)str, len, MADV_NORMAL);

	return utf8;
}






























@implementation OFString
+ string
{
	return [[[self alloc] init] autorelease];
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







100
101
102
103
104
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
141
142
		i += 3;
	}

	madvise((void*)str, len, MADV_NORMAL);

	return utf8;
}

size_t
of_string_unicode_to_utf8(uint32_t c, uint8_t *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
+ string
{
	return [[[self alloc] init] autorelease];
}