ObjFW  Diff

Differences From Artifact [97c02a6c42]:

  • File src/OFString_UTF8.m — part of check-in [50916b8dbe] at 2013-01-11 12:41:54 on branch trunk — OFString: Improve API for characters / UTF-32.

    With this change, there is a clear separation between characters and
    UTF-32 strings now. Characters are just an array of characters in the
    native endianess, with no BOM prepended. UTF-32 on the other hand may
    have a BOM and can be swapped and is optionally zero-terminated.

    This also fixes a few missing UTF-16 init methods in OFMutableString. (user: js, size: 30904) [annotate] [blame] [check-ins using]

To Artifact [c16c78a6d7]:


772
773
774
775
776
777
778
779

780
781
782
783
784
785
786
787
788
789
790
791

792
793
794
795
796
797
798
799
800
801
802
803
804
805

806
807
808
809
810
811
812

813
814
815
816
817
818
819
772
773
774
775
776
777
778

779
780
781
782
783
784
785
786
787
788
789
790

791
792
793
794
795
796
797
798
799
800
801
802
803
804

805
806
807
808
809
810
811

812
813
814
815
816
817
818
819







-
+











-
+













-
+






-
+







{
	if (s != NULL && s->freeWhenDone != NULL)
		free(s->freeWhenDone);

	[super dealloc];
}

- (const char*)cStringUsingEncoding: (of_string_encoding_t)encoding
- (const char*)cStringWithEncoding: (of_string_encoding_t)encoding
{
	switch (encoding) {
	case OF_STRING_ENCODING_UTF_8:
		return s->cString;
	case OF_STRING_ENCODING_ASCII:
		if (s->isUTF8)
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];

		return s->cString;
	default:
		return [super cStringUsingEncoding: encoding];
		return [super cStringWithEncoding: encoding];
	}
}

- (const char*)UTF8String
{
	return s->cString;
}

- (size_t)length
{
	return s->length;
}

- (size_t)lengthOfBytesUsingEncoding: (of_string_encoding_t)encoding
- (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding
{
	switch (encoding) {
	case OF_STRING_ENCODING_UTF_8:
	case OF_STRING_ENCODING_ASCII:
		return s->cStringLength;
	default:
		return [super lengthOfBytesUsingEncoding: encoding];
		return [super cStringLengthWithEncoding: encoding];
	}
}

- (size_t)UTF8StringLength
{
	return s->cStringLength;
}