Flutter Engine
The Flutter Engine
string_range_sanitization.h
Go to the documentation of this file.
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_PLATFORM_DARWIN_STRING_RANGE_SANITIZATION_H_
6#define FLUTTER_FML_PLATFORM_DARWIN_STRING_RANGE_SANITIZATION_H_
7
8#include <Foundation/Foundation.h>
9
10namespace 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)`.
16NSRange 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)`.
25NSRange RangeForCharactersInRange(NSString* text, NSRange range);
26
27} // namespace fml
28
29#endif // FLUTTER_FML_PLATFORM_DARWIN_STRING_RANGE_SANITIZATION_H_
std::u16string text
Definition: ascii_trie.cc:9
NSRange RangeForCharacterAtIndex(NSString *text, NSUInteger index)
NSRange RangeForCharactersInRange(NSString *text, NSRange range)