1 | /*-------------------------------------------------------------------------------------------------------*\ |
---|
2 | | Adium, Copyright (C) 2001-2005, Adam Iser (adamiser@mac.com | http://www.adiumx.com) | |
---|
3 | \---------------------------------------------------------------------------------------------------------/ |
---|
4 | | This program is free software; you can redistribute it and/or modify it under the terms of the GNU |
---|
5 | | General Public License as published by the Free Software Foundation; either version 2 of the License, |
---|
6 | | or (at your option) any later version. |
---|
7 | | |
---|
8 | | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
---|
9 | | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
10 | | Public License for more details. |
---|
11 | | |
---|
12 | | You should have received a copy of the GNU General Public License along with this program; if not, |
---|
13 | | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
14 | \------------------------------------------------------------------------------------------------------ */ |
---|
15 | |
---|
16 | #import <AIUtilities/AITigerCompatibility.h> |
---|
17 | |
---|
18 | @interface NSString (AIStringAdditions) |
---|
19 | |
---|
20 | + (id)randomStringOfLength:(unsigned int)inLength; |
---|
21 | |
---|
22 | + (id)stringWithContentsOfUTF8File:(NSString *)path; |
---|
23 | |
---|
24 | + (id)stringWithData:(NSData *)data encoding:(NSStringEncoding)encoding; |
---|
25 | + (id)stringWithBytes:(const void *)inBytes length:(unsigned)inLength encoding:(NSStringEncoding)inEncoding; |
---|
26 | |
---|
27 | + (id)ellipsis; |
---|
28 | - (NSString *)stringByAppendingEllipsis; |
---|
29 | |
---|
30 | - (NSString *)stringByTranslatingByOffset:(int)offset; |
---|
31 | |
---|
32 | - (NSString *)compactedString; |
---|
33 | |
---|
34 | - (NSString *)stringByExpandingBundlePath; |
---|
35 | - (NSString *)stringByCollapsingBundlePath; |
---|
36 | |
---|
37 | - (NSString *)stringByEncodingURLEscapes; |
---|
38 | - (NSString *)stringByDecodingURLEscapes; |
---|
39 | |
---|
40 | - (NSString *)safeFilenameString; |
---|
41 | |
---|
42 | - (NSString *)stringWithEllipsisByTruncatingToLength:(unsigned int)length; |
---|
43 | |
---|
44 | - (NSString *)string; |
---|
45 | |
---|
46 | /*! |
---|
47 | * @brief Wraps CFXMLCreateStringByEscapingEntities() with the addition of escaping whitespace if no entities dictionary is specified. See its documentation. |
---|
48 | */ |
---|
49 | - (NSString *)stringByEscapingForXMLWithEntities:(NSDictionary *)entities; |
---|
50 | |
---|
51 | /*! |
---|
52 | * @brief Wraps CFXMLCreateStringByUnescapingEntities(). See its documentation. |
---|
53 | */ |
---|
54 | - (NSString *)stringByUnescapingFromXMLWithEntities:(NSDictionary *)entities; |
---|
55 | |
---|
56 | - (NSString *)stringByEscapingForShell; |
---|
57 | //- (BOOL)isURLEncoded; |
---|
58 | |
---|
59 | /*examples: |
---|
60 | * receiver result |
---|
61 | * ======== ====== |
---|
62 | * / / |
---|
63 | * /Users/boredzo / |
---|
64 | * /Volumes/Repository /Volumes/Repository |
---|
65 | * /Volumes/Repository/Downloads /Volumes/Repository |
---|
66 | *and if /Volumes/Toolbox is your startup disk (as it is mine): |
---|
67 | * /Volumes/Toolbox/Applications / |
---|
68 | */ |
---|
69 | - (NSString *)volumePath; |
---|
70 | |
---|
71 | - (unichar)lastCharacter; |
---|
72 | - (unichar)nextToLastCharacter; |
---|
73 | - (UTF32Char)lastLongCharacter; |
---|
74 | |
---|
75 | + (NSString *)uuid; |
---|
76 | |
---|
77 | + (NSString *)stringWithFloat:(float)f maxDigits:(unsigned)numDigits; |
---|
78 | |
---|
79 | /*! |
---|
80 | * @brief Finds a line-breaking character within a substring of a string. |
---|
81 | * |
---|
82 | * A line-breaking character is any of LF (U+000A), FF (U+000C), CR (U+000D), |
---|
83 | * NEXT LINE (U+0085), LINE SEPARATOR (U+2028), or PARAGRAPH SEPARATOR (U+2029). |
---|
84 | * |
---|
85 | * @par |
---|
86 | * If this method detects a CRLF sequence, it will turn the range covering both characters. For all other line breaks, the range it returns has length 1. |
---|
87 | * |
---|
88 | * @param range The range (within the receiver) where you want to look for a line-break character. |
---|
89 | * @throws NSRangeException Some part of \a range lies outside the receiver's bounds. |
---|
90 | * @result The range of the line break, or { NSNotFound, 0 } if no line-breaking character is present within the substring. |
---|
91 | */ |
---|
92 | - (NSRange) rangeOfLineBreakCharacterInRange:(NSRange)range; |
---|
93 | /*! |
---|
94 | * @brief Finds a line-breaking character in the latter portion of a string. |
---|
95 | * |
---|
96 | * A line-breaking character is any of LF (U+000A), FF (U+000C), CR (U+000D), |
---|
97 | * NEXT LINE (U+0085), LINE SEPARATOR (U+2028), or PARAGRAPH SEPARATOR (U+2029). |
---|
98 | * |
---|
99 | * @par |
---|
100 | * If this method detects a CRLF sequence, it will turn the range covering both characters. For all other line breaks, the range it returns has length 1. |
---|
101 | * |
---|
102 | * @par |
---|
103 | * This method will look for the character within the range { startIdx, length - startIdx }. |
---|
104 | * |
---|
105 | * @param startIdx The index (within the receiver) from which you want to start looking for a line-break character. |
---|
106 | * @throws NSRangeException \a startIdx lies outside the receiver's bounds. |
---|
107 | * @result The range of the line break, or { NSNotFound, 0 } if no line-breaking character is present within the substring. |
---|
108 | */ |
---|
109 | - (NSRange) rangeOfLineBreakCharacterFromIndex:(NSUInteger)startIdx; |
---|
110 | /*! |
---|
111 | * @brief Finds a line-breaking character within a string. |
---|
112 | * |
---|
113 | * A line-breaking character is any of LF (U+000A), FF (U+000C), CR (U+000D), |
---|
114 | * NEXT LINE (U+0085), LINE SEPARATOR (U+2028), or PARAGRAPH SEPARATOR (U+2029). |
---|
115 | * |
---|
116 | * @par |
---|
117 | * If this method detects a CRLF sequence, it will turn the range covering both characters. For all other line breaks, the range it returns has length 1. |
---|
118 | * |
---|
119 | * @result The range of the line break, or { NSNotFound, 0 } if no line-breaking character is present within the string. |
---|
120 | */ |
---|
121 | - (NSRange) rangeOfLineBreakCharacter; |
---|
122 | |
---|
123 | //If you provide a separator object, it will be recorded in the array whenever a newline is encountered. |
---|
124 | //Newline is any of CR, LF, CRLF, LINE SEPARATOR, or PARAGRAPH SEPARATOR. |
---|
125 | //If you do not provide a separator object (pass nil or use the other method), separators are not recorded; you get only the lines, with nothing between them. |
---|
126 | - (NSArray *)allLinesWithSeparator:(NSObject *)separatorObj; |
---|
127 | - (NSArray *)allLines; |
---|
128 | |
---|
129 | @end |
---|