ObjFW  Diff

Differences From Artifact [581a424007]:

To Artifact [6df5a31603]:


755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
		string = [self allocMemoryWithSize: (length * 4) + 1];

		for (i = 0; i < length_; i++) {
			of_unichar_t character =
			    (swap ? of_bswap16(string_[i]) : string_[i]);
			size_t characterLen;

			/* Missed the high surrogate */
			if ((character & 0xFC00) == 0xDC00)
				@throw [OFInvalidEncodingException
				    newWithClass: isa];

			if ((character & 0xFC00) == 0xD800) {
				uint16_t nextCharacter;








|







755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
		string = [self allocMemoryWithSize: (length * 4) + 1];

		for (i = 0; i < length_; i++) {
			of_unichar_t character =
			    (swap ? of_bswap16(string_[i]) : string_[i]);
			size_t characterLen;

			/* Missing high surrogate */
			if ((character & 0xFC00) == 0xDC00)
				@throw [OFInvalidEncodingException
				    newWithClass: isa];

			if ((character & 0xFC00) == 0xD800) {
				uint16_t nextCharacter;

1067
1068
1069
1070
1071
1072
1073























1074
1075
1076
1077
1078
1079
1080
		encoding = OF_STRING_ENCODING_UTF_8;

	self = [[c alloc] initWithCString: (char*)[[result data] cArray]
				 encoding: encoding
				   length: [[result data] count]];

	[pool release];























	return self;
}

- (const char*)cString
{
	return string;
}







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







1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
		encoding = OF_STRING_ENCODING_UTF_8;

	self = [[c alloc] initWithCString: (char*)[[result data] cArray]
				 encoding: encoding
				   length: [[result data] count]];

	[pool release];
	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

		if (![[element name] isEqual: @"object"] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
		    ![[[element attributeForName: @"class"] stringValue]
		    isEqual: [isa className]])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		self = [self initWithString: [element stringValue]];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (const char*)cString
{
	return string;
}