Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
NSStringOOExtensions.h
Go to the documentation of this file.
1/*
2
3NSStringOOExtensions.h
4
5Convenience extensions to NSString.
6
7Oolite
8Copyright (C) 2004-2013 Giles C Williams and contributors
9
10This program is free software; you can redistribute it and/or
11modify it under the terms of the GNU General Public License
12as published by the Free Software Foundation; either version 2
13of the License, or (at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23MA 02110-1301, USA.
24
25*/
26
27#import "OOCocoa.h"
28
29
30@interface NSString (OOExtensions)
31
32/* +stringWithContentsOfUnicodeFile:
33
34 Like +stringWithContentsOfFile:, but biased towards Unicode encodings and
35 cross-system consistency. Specifically:
36 * If the file starts with a UTF-16 BOM, assume UTF-16.
37 * Otherwise, if the file can be interpreted as UTF-8, assume UTF-8.
38 * Otherwise, assume ISO-Latin-1.
39*/
40+ (instancetype) stringWithContentsOfUnicodeFile:(NSString *)path;
41
42
43/* +stringWithUTF16String:
44
45 Takes a NUL-terminated native-endian UTF-16 string.
46*/
47+ (instancetype) stringWithUTF16String:(const unichar *)chars;
48
49
50/* -utf16DataWithBOM:
51 Convert to native-endian UTF-16 data.
52*/
53- (NSData *) utf16DataWithBOM:(BOOL)includeByteOrderMark;
54
55/* - oo_hash
56 Hash function for when we want consistency across platforms and versions.
57 It implements modified djb2 (with xor rather than addition) in terms of
58 UTF-16 code elements.
59*/
60- (uint32_t) oo_hash;
61
62@end
63
64
65@interface NSMutableString (OOExtensions)
66
67- (void) appendLine:(NSString *)line;
68- (void) appendFormatLine:(NSString *)fmt, ...;
69- (void) appendFormatLine:(NSString *)fmt arguments:(va_list)args;
70
71- (void) deleteCharacterAtIndex:(unsigned long)index;
72
73@end
74
75
76/* OOTabString(count)
77
78 Return a string of <count> tabs.
79*/
80NSString *OOTabString(NSUInteger count);
NSString * OOTabString(NSUInteger count)
unsigned count