ObjFW  Check-in [db06863643]

Overview
Comment:Add -[OFString dataWithEncoding:]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: db068636438512225bb9eb57a9c4a646220af663dd6b6405326ab803b057e106
User & Date: js on 2017-07-23 18:02:25
Other Links: manifest | tags
Context
2017-07-24
20:10
OFData: Add casts to make 32 bit Clang happy check-in: 8da165721c user: js tags: trunk
2017-07-23
18:02
Add -[OFString dataWithEncoding:] check-in: db06863643 user: js tags: trunk
17:55
Add +[OFString stringWithData:encoding:] check-in: 9aacc26542 user: js tags: trunk
Changes

Modified src/OFConstantString.m from [33c7229c0d] to [a025049426].

602
603
604
605
606
607
608







609
610
611
612
613
614
615
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622







+
+
+
+
+
+
+








- (const char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder
{
	[self finishInitialization];

	return [self UTF32StringWithByteOrder: byteOrder];
}

- (OFData *)dataWithEncoding: (of_string_encoding_t)encoding
{
	[self finishInitialization];

	return [self dataWithEncoding: encoding];
}

#ifdef OF_HAVE_UNICODE_TABLES
- (OFString *)decomposedStringWithCanonicalMapping
{
	[self finishInitialization];

	return [self decomposedStringWithCanonicalMapping];

Modified src/OFString.h from [89bf3fd41c] to [f5efa5d129].

1119
1120
1121
1122
1123
1124
1125








1126
1127
1128
1129
1130
1131
1132
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140







+
+
+
+
+
+
+
+







 *
 * @param byteOrder The byte order for the UTF-32 encoding
 * @return The string in UTF-32 encoding with the specified byte order
 */
- (const char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder
    OF_RETURNS_INNER_POINTER;

/*!
 * @brief Returns the string as OFData with the specified encoding.
 *
 * @param encoding The encoding to use for the returned OFData
 * @return The string as OFData with the specified encoding
 */
- (OFData *)dataWithEncoding: (of_string_encoding_t)encoding;

#ifdef OF_HAVE_UNICODE_TABLES
/*!
 * @brief Returns the string in Unicode Normalization Form D (NFD).
 *
 * @return The string in Unicode Normalization Form D (NFD)
 */
- (OFString *)decomposedStringWithCanonicalMapping;

Modified src/OFString.m from [3b9b1e2811] to [fc3a0af468].

2767
2768
2769
2770
2771
2772
2773














2774
2775
2776
2777
2778
2779
2780
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794







+
+
+
+
+
+
+
+
+
+
+
+
+
+








	if (byteOrder != OF_BYTE_ORDER_NATIVE)
		for (size_t i = 0; i < length; i++)
			ret[i] = OF_BSWAP32(ret[i]);

	return ret;
}

- (OFData *)dataWithEncoding: (of_string_encoding_t)encoding
{
	void *pool = objc_autoreleasePoolPush();
	OFData *data =
	    [OFData dataWithItems: [self cStringWithEncoding: encoding]
			    count: [self cStringLengthWithEncoding: encoding]];

	[data retain];

	objc_autoreleasePoolPop(pool);

	return [data autorelease];
}

#ifdef OF_HAVE_UNICODE_TABLES
- (OFString *)decomposedStringWithCanonicalMapping
{
	return decomposedString(self, of_unicode_decomposition_table,
	    OF_UNICODE_DECOMPOSITION_TABLE_SIZE);
}