• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter 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 FLUTTER_FML_STRING_RANGE_SANITIZATION_H_
6 #define FLUTTER_FML_STRING_RANGE_SANITIZATION_H_
7 
8 #include <Foundation/Foundation.h>
9 
10 namespace fml {
11 
12 // Returns a range encompassing the grapheme cluster in which |index| is located.
13 //
14 // A nil |text| or an index greater than or equal to text.length will result in
15 // `NSRange(NSNotFound, 0)`.
16 NSRange RangeForCharacterAtIndex(NSString* text, NSUInteger index);
17 
18 // Returns a range encompassing the grapheme clusters falling in |range|.
19 //
20 // This method will not alter the length of the input range, but will ensure
21 // that the range's location is not in the middle of a multi-byte unicode
22 // sequence.
23 //
24 // An invalid range will result in `NSRange(NSNotFound, 0)`.
25 NSRange RangeForCharactersInRange(NSString* text, NSRange range);
26 
27 }  // namespace fml
28 
29 #endif  // FLUTTER_FML_STRING_RANGE_SANITIZATION_H_
30