OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/spellcheck_worditerator.h" | 5 #include "chrome/browser/spellcheck_worditerator.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // Retrieves a word (or a contraction). | 178 // Retrieves a word (or a contraction). |
179 // When a contraction is enclosed with contraction characters (e.g. 'isn't', | 179 // When a contraction is enclosed with contraction characters (e.g. 'isn't', |
180 // 'rock'n'roll'), we should discard the beginning and the end of the | 180 // 'rock'n'roll'), we should discard the beginning and the end of the |
181 // contraction but we should never split the contraction. | 181 // contraction but we should never split the contraction. |
182 // To handle this case easily, we should firstly extract a segment consisting | 182 // To handle this case easily, we should firstly extract a segment consisting |
183 // of word characters and contraction characters, and discard contraction | 183 // of word characters and contraction characters, and discard contraction |
184 // characters at the beginning and the end of the extracted segment. | 184 // characters at the beginning and the end of the extracted segment. |
185 bool SpellcheckWordIterator::GetNextWord(string16* word_string, | 185 bool SpellcheckWordIterator::GetNextWord(string16* word_string, |
186 int* word_start, | 186 int* word_start, |
187 int* word_length) { | 187 int* word_length) { |
188 word_string->empty(); | 188 word_string->clear(); |
189 *word_start = 0; | 189 *word_start = 0; |
190 *word_length = 0; | 190 *word_length = 0; |
191 while (position_ < length_) { | 191 while (position_ < length_) { |
192 int segment_start = 0; | 192 int segment_start = 0; |
193 int segment_end = 0; | 193 int segment_end = 0; |
194 GetSegment(&segment_start, &segment_end); | 194 GetSegment(&segment_start, &segment_end); |
195 TrimSegment(segment_start, segment_end, word_start, word_length); | 195 TrimSegment(segment_start, segment_end, word_start, word_length); |
196 if (*word_length > 0) | 196 if (*word_length > 0) |
197 return Normalize(*word_start, *word_length, word_string); | 197 return Normalize(*word_start, *word_length, word_string); |
198 } | 198 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 // alternatives, but also write NFKC keeps accents of characters. | 265 // alternatives, but also write NFKC keeps accents of characters. |
266 // Therefore, NFKC seems to be the best option for hunspell. | 266 // Therefore, NFKC seems to be the best option for hunspell. |
267 icu::UnicodeString input(FALSE, &word_[input_start], input_length); | 267 icu::UnicodeString input(FALSE, &word_[input_start], input_length); |
268 UErrorCode status = U_ZERO_ERROR; | 268 UErrorCode status = U_ZERO_ERROR; |
269 icu::UnicodeString output; | 269 icu::UnicodeString output; |
270 icu::Normalizer::normalize(input, UNORM_NFKC, 0, output, status); | 270 icu::Normalizer::normalize(input, UNORM_NFKC, 0, output, status); |
271 if (U_SUCCESS(status)) | 271 if (U_SUCCESS(status)) |
272 output_string->assign(output.getTerminatedBuffer()); | 272 output_string->assign(output.getTerminatedBuffer()); |
273 return status == U_ZERO_ERROR || status == U_STRING_NOT_TERMINATED_WARNING; | 273 return status == U_ZERO_ERROR || status == U_STRING_NOT_TERMINATED_WARNING; |
274 } | 274 } |
OLD | NEW |