68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
s->cString = [self allocMemoryWithSize: 1];
s->cString[0] = '\0';
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithCString: (const char*)cString
encoding: (of_string_encoding_t)encoding
length: (size_t)cStringLength
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
s->cString = [self allocMemoryWithSize: 1];
s->cString[0] = '\0';
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- _initWithUTF8String: (const char*)UTF8String
length: (size_t)UTF8StringLength
storage: (char*)storage
{
self = [super init];
@try {
if (UTF8StringLength >= 3 &&
!memcmp(UTF8String, "\xEF\xBB\xBF", 3)) {
UTF8String += 3;
UTF8StringLength -= 3;
}
s = &s_store;
s->cString = storage;
s->cStringLength = UTF8StringLength;
switch (of_string_check_utf8(UTF8String, UTF8StringLength,
&s->length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
memcpy(s->cString, UTF8String, UTF8StringLength);
s->cString[UTF8StringLength] = 0;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithCString: (const char*)cString
encoding: (of_string_encoding_t)encoding
length: (size_t)cStringLength
|