mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
30 lines
1.0 KiB
C++
30 lines
1.0 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef FLUTTER_FML_STRING_RANGE_SANITIZATION_H_
|
|
#define FLUTTER_FML_STRING_RANGE_SANITIZATION_H_
|
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
namespace fml {
|
|
|
|
// Returns a range encompassing the grapheme cluster in which |index| is located.
|
|
//
|
|
// A nil |text| or an index greater than or equal to text.length will result in
|
|
// `NSRange(NSNotFound, 0)`.
|
|
NSRange RangeForCharacterAtIndex(NSString* text, NSUInteger index);
|
|
|
|
// Returns a range encompassing the grapheme clusters falling in |range|.
|
|
//
|
|
// This method will not alter the length of the input range, but will ensure
|
|
// that the range's location is not in the middle of a multi-byte unicode
|
|
// sequence.
|
|
//
|
|
// An invalid range will result in `NSRange(NSNotFound, 0)`.
|
|
NSRange RangeForCharactersInRange(NSString* text, NSRange range);
|
|
|
|
} // namespace fml
|
|
|
|
#endif // FLUTTER_FML_STRING_RANGE_SANITIZATION_H_
|