Overview
Comment: | Add -[cStringWithEncoding:] and -[cStringLengthWithEncoding:]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
90369e9323e361c77d8d3143e99727e6 |
User & Date: | js on 2011-09-12 18:57:16 |
Other Links: | manifest | tags |
Context
2011-09-12
| ||
19:14 | Remove -[setToCString:]. check-in: d511962e09 user: js tags: trunk | |
18:57 | Add -[cStringWithEncoding:] and -[cStringLengthWithEncoding:]. check-in: 90369e9323 user: js tags: trunk | |
18:40 | Add OF_STRING_ENCODING_NATIVE. check-in: 96e70bb9c4 user: js tags: trunk | |
Changes
Modified src/OFString.h from [24d1b609ed] to [fad2ce5911].
︙ | ︙ | |||
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | /** * \brief Returns the OFString as a UTF-8 encoded C string. * * \return The OFString as a UTF-8 encoded C string */ - (const char*)cString; /** * \brief Returns the length of the string in Unicode characters. * * \return The length of the string in Unicode characters */ - (size_t)length; /** * \brief Returns the length of the string which cString would return. * * \return The length of the string which cString would return */ - (size_t)cStringLength; /** * \brief Compares the OFString to another OFString without caring about the * case. * * \param otherString A string to compare with * \return An of_comparison_result_t */ | > > > > > > > > > > > > > > > > > | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | /** * \brief Returns the OFString as a UTF-8 encoded C string. * * \return The OFString as a UTF-8 encoded C string */ - (const char*)cString; /** * \brief Returns the OFString as a C string in the specified encoding. * * \param encoding The encoding for the C string * \return The OFString as a C string in the specified encoding */ - (const char*)cStringWithEncoding: (of_string_encoding_t)encoding;; /** * \brief Returns the length of the string in Unicode characters. * * \return The length of the string in Unicode characters */ - (size_t)length; /** * \brief Returns the length of the string which cString would return. * * \return The length of the string which cString would return */ - (size_t)cStringLength; /** * \brief Returns the number of bytes the string needs in the specified * encoding. * * \param encoding The encoding for the string * \return The number of bytes the string needs in the specified encoding. */ - (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding; /** * \brief Compares the OFString to another OFString without caring about the * case. * * \param otherString A string to compare with * \return An of_comparison_result_t */ |
︙ | ︙ |
Modified src/OFString.m from [a0631a1efb] to [21b462a461].
︙ | ︙ | |||
41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #import "OFAutoreleasePool.h" #import "OFHTTPRequestFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFOpenFileFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "macros.h" #import "of_asprintf.h" #import "unicode.h" | > | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #import "OFAutoreleasePool.h" #import "OFHTTPRequestFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFOpenFileFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "macros.h" #import "of_asprintf.h" #import "unicode.h" |
︙ | ︙ | |||
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 | return self; } - (const char*)cString { return s->cString; } - (size_t)length { return s->length; } - (size_t)cStringLength { return s->cStringLength; } - (BOOL)isEqual: (id)object { OFString *otherString; if (![object isKindOfClass: [OFString class]]) return NO; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 | return self; } - (const char*)cString { 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 newWithClass: isa]; return s->cString; default: @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } } - (size_t)length { return s->length; } - (size_t)cStringLength { 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 newWithClass: isa]; return s->cStringLength; default: @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } } - (BOOL)isEqual: (id)object { OFString *otherString; if (![object isKindOfClass: [OFString class]]) return NO; |
︙ | ︙ |