OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_BASE_TEXT_UTF16_INDEXING_H_ | 5 #ifndef UI_GFX_UTF16_INDEXING_H_ |
6 #define UI_BASE_TEXT_UTF16_INDEXING_H_ | 6 #define UI_GFX_UTF16_INDEXING_H_ |
7 | 7 |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "ui/base/ui_export.h" | 9 #include "ui/gfx/gfx_export.h" |
10 | 10 |
11 namespace ui { | 11 namespace gfx { |
12 | 12 |
13 // Returns false if s[index-1] is a high surrogate and s[index] is a low | 13 // Returns false if s[index-1] is a high surrogate and s[index] is a low |
14 // surrogate, true otherwise. | 14 // surrogate, true otherwise. |
15 UI_EXPORT bool IsValidCodePointIndex(const string16& s, size_t index); | 15 UI_EXPORT bool IsValidCodePointIndex(const string16& s, size_t index); |
16 | 16 |
17 // |UTF16IndexToOffset| returns the number of code points between |base| and | 17 // |UTF16IndexToOffset| returns the number of code points between |base| and |
18 // |pos| in the given string. |UTF16OffsetToIndex| returns the index that is | 18 // |pos| in the given string. |UTF16OffsetToIndex| returns the index that is |
19 // |offset| code points away from the given |base| index. These functions are | 19 // |offset| code points away from the given |base| index. These functions are |
20 // named after glib's |g_utf8_pointer_to_offset| and |g_utf8_offset_to_pointer|, | 20 // named after glib's |g_utf8_pointer_to_offset| and |g_utf8_offset_to_pointer|, |
21 // which perform the same function for UTF-8. As in glib, it is an error to | 21 // which perform the same function for UTF-8. As in glib, it is an error to |
(...skipping 15 matching lines...) Expand all Loading... |
37 // Always, | 37 // Always, |
38 // UTF16IndexToOffset(s, base, UTF16OffsetToIndex(s, base, ofs)) == ofs | 38 // UTF16IndexToOffset(s, base, UTF16OffsetToIndex(s, base, ofs)) == ofs |
39 // UTF16IndexToOffset(s, i, j) == -UTF16IndexToOffset(s, j, i) | 39 // UTF16IndexToOffset(s, i, j) == -UTF16IndexToOffset(s, j, i) |
40 UI_EXPORT ptrdiff_t UTF16IndexToOffset(const string16& s, | 40 UI_EXPORT ptrdiff_t UTF16IndexToOffset(const string16& s, |
41 size_t base, | 41 size_t base, |
42 size_t pos); | 42 size_t pos); |
43 UI_EXPORT size_t UTF16OffsetToIndex(const string16& s, | 43 UI_EXPORT size_t UTF16OffsetToIndex(const string16& s, |
44 size_t base, | 44 size_t base, |
45 ptrdiff_t offset); | 45 ptrdiff_t offset); |
46 | 46 |
47 } // namespace ui | 47 } // namespace gfx |
48 | 48 |
49 #endif // UI_BASE_TEXT_UTF16_INDEXING_H_ | 49 #endif // UI_GFX_UTF16_INDEXING_H_ |
OLD | NEW |