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
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
|
{
if (s != NULL && s->freeWhenDone != NULL)
free(s->freeWhenDone);
[super dealloc];
}
- (const char*)UTF8String
{
return s->cString;
}
- (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:
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: _cmd];
}
}
- (size_t)length
{
return s->length;
}
- (size_t)UTF8StringLength
{
return s->cStringLength;
}
- (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding
{
switch (encoding) {
case OF_STRING_ENCODING_UTF_8:
return s->cStringLength;
case OF_STRING_ENCODING_ASCII:
if (s->isUTF8)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
return s->cStringLength;
default:
@throw [OFNotImplementedException
exceptionWithClass: [self class]
selector: _cmd];
}
}
- (BOOL)isEqual: (id)object
{
OFString_UTF8 *otherString;
if (object == self)
return YES;
|
<
<
<
<
<
|
|
<
<
>
>
>
>
>
<
<
<
<
<
|
|
<
<
>
>
>
>
>
|
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
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
|
{
if (s != NULL && s->freeWhenDone != NULL)
free(s->freeWhenDone);
[super dealloc];
}
- (const char*)cStringUsingEncoding: (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];
}
}
- (const char*)UTF8String
{
return s->cString;
}
- (size_t)length
{
return s->length;
}
- (size_t)lengthOfBytesUsingEncoding: (of_string_encoding_t)encoding
{
switch (encoding) {
case OF_STRING_ENCODING_UTF_8:
return s->cStringLength;
case OF_STRING_ENCODING_ASCII:
if (s->isUTF8)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
return s->cStringLength;
default:
return [super lengthOfBytesUsingEncoding: encoding];
}
}
- (size_t)UTF8StringLength
{
return s->cStringLength;
}
- (BOOL)isEqual: (id)object
{
OFString_UTF8 *otherString;
if (object == self)
return YES;
|