| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef IOS_CHROME_COMMON_STRING_UTIL_H_ | |
| 6 #define IOS_CHROME_COMMON_STRING_UTIL_H_ | |
| 7 | |
| 8 #import <CoreGraphics/CoreGraphics.h> | |
| 9 #import <Foundation/Foundation.h> | |
| 10 #include <string> | |
| 11 | |
| 12 // Parses a string with an embedded link inside, delineated by BEGIN_LINK and | |
| 13 // END_LINK. Returns the string without the link delimiters. If |out_link_range| | |
| 14 // is not null, then it is filled out with the range of the link in the returned | |
| 15 // string. | |
| 16 // If no link is found, then it returns |text| and sets |out_link_range| to | |
| 17 // {NSNotFound, 0}. | |
| 18 NSString* ParseStringWithLink(NSString* text, NSRange* out_link_range); | |
| 19 | |
| 20 // Utility method that returns an NSCharacterSet containing Unicode graphics | |
| 21 // and drawing characters (but not including the Braille Patterns characters). | |
| 22 NSCharacterSet* GraphicCharactersSet(); | |
| 23 | |
| 24 // Cleans an NSString by collapsing whitespace and (if |trim| is true) | |
| 25 // removing leading and trailing spaces. If |removeGraphicChars| is true, | |
| 26 // unicode graphic characters will also be removed from the string. | |
| 27 NSString* CleanNSStringForDisplay(NSString* dirty, | |
| 28 BOOL removeGraphicChars, | |
| 29 BOOL trim); | |
| 30 | |
| 31 // Cleans a std::string identically to CleanNSStringForDisplay() | |
| 32 std::string CleanStringForDisplay(std::string dirty, | |
| 33 BOOL removeGraphicChars, | |
| 34 BOOL trim); | |
| 35 | |
| 36 // Find the longest leading substring of |string| that, when rendered with | |
| 37 // |attributes|, will fit on a single line inside |targetWidth|. If |trailing| | |
| 38 // is YES, then find the trailing (instead of leading) substring. | |
| 39 NSString* SubstringOfWidth(NSString* string, | |
| 40 NSDictionary* attributes, | |
| 41 CGFloat targetWidth, | |
| 42 BOOL trailing); | |
| 43 | |
| 44 #endif // IOS_CHROME_COMMON_STRING_UTIL_H_ | |
| OLD | NEW |