Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 38 lines (28 sloc) 0.786 kb
9079389 @Cocoanetics Added convenience function to trim whitespace at end of mutable string.
authored
1 //
2 // NSMutableString+HTML.m
3 // DTCoreText
4 //
5 // Created by Oliver Drobnik on 01.02.12.
6 // Copyright (c) 2012 Drobnik.com. All rights reserved.
7 //
8
9 #import "NSMutableString+HTML.h"
10
11
12 #define IS_WHITESPACE(_c) (_c == ' ' || _c == '\t' || _c == 0xA || _c == 0xB || _c == 0xC || _c == 0xD || _c == 0x85)
13
14 @implementation NSMutableString (HTML)
15
c147030 @joepasq Added documentation to NSMutableString+HTML. Changed method name from…
joepasq authored
16 - (void)removeTrailingWhitespace
9079389 @Cocoanetics Added convenience function to trim whitespace at end of mutable string.
authored
17 {
18 NSUInteger length = self.length;
19
20 NSInteger lastIndex = length-1;
21 NSInteger index = lastIndex;
22 NSInteger whitespaceLength = 0;
23
24 while (index>=0 && IS_WHITESPACE([self characterAtIndex:index]))
25 {
26 index--;
27 whitespaceLength++;
28 }
29
30 // do the removal once for all whitespace characters
31 if (whitespaceLength)
32 {
33 [self deleteCharactersInRange:NSMakeRange(index+1, whitespaceLength)];
34 }
35 }
36
37 @end
Something went wrong with that request. Please try again.