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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 for (size_t i = 0; i < arraysize(kMidLetters); ++i) | 53 for (size_t i = 0; i < arraysize(kMidLetters); ++i) |
54 middle_letters_[kMidLetters[i]] = true; | 54 middle_letters_[kMidLetters[i]] = true; |
55 } | 55 } |
56 | 56 |
57 SpellcheckCharAttribute::~SpellcheckCharAttribute() { | 57 SpellcheckCharAttribute::~SpellcheckCharAttribute() { |
58 } | 58 } |
59 | 59 |
60 // Sets the default language for this object. | 60 // Sets the default language for this object. |
61 // This function retrieves the exemplar set to set up the default character | 61 // This function retrieves the exemplar set to set up the default character |
62 // attributes. | 62 // attributes. |
63 void SpellcheckCharAttribute::SetDefaultLanguage( | 63 void SpellcheckCharAttribute::SetDefaultLanguage(const std::string& language) { |
64 const SpellChecker::Language& language) { | |
65 UErrorCode status = U_ZERO_ERROR; | 64 UErrorCode status = U_ZERO_ERROR; |
66 ULocaleData* locale_data = ulocdata_open(language.c_str(), &status); | 65 ULocaleData* locale_data = ulocdata_open(language.c_str(), &status); |
67 if (U_FAILURE(status)) | 66 if (U_FAILURE(status)) |
68 return; | 67 return; |
69 | 68 |
70 // Retrieves the exemplar set of the given language and update the | 69 // Retrieves the exemplar set of the given language and update the |
71 // character-attribute table to treat its characters as word characters. | 70 // character-attribute table to treat its characters as word characters. |
72 USet* exemplar_set = uset_open(1, 0); | 71 USet* exemplar_set = uset_open(1, 0); |
73 ulocdata_getExemplarSet(locale_data, exemplar_set, 0, ULOCDATA_ES_STANDARD, | 72 ulocdata_getExemplarSet(locale_data, exemplar_set, 0, ULOCDATA_ES_STANDARD, |
74 &status); | 73 &status); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // alternatives, but also write NFKC keeps accents of characters. | 265 // alternatives, but also write NFKC keeps accents of characters. |
267 // Therefore, NFKC seems to be the best option for hunspell. | 266 // Therefore, NFKC seems to be the best option for hunspell. |
268 UnicodeString input(FALSE, &word_[input_start], input_length); | 267 UnicodeString input(FALSE, &word_[input_start], input_length); |
269 UErrorCode status = U_ZERO_ERROR; | 268 UErrorCode status = U_ZERO_ERROR; |
270 UnicodeString output; | 269 UnicodeString output; |
271 Normalizer::normalize(input, UNORM_NFKC, 0, output, status); | 270 Normalizer::normalize(input, UNORM_NFKC, 0, output, status); |
272 if (U_SUCCESS(status)) | 271 if (U_SUCCESS(status)) |
273 output_string->assign(output.getTerminatedBuffer()); | 272 output_string->assign(output.getTerminatedBuffer()); |
274 return status == U_ZERO_ERROR || status == U_STRING_NOT_TERMINATED_WARNING; | 273 return status == U_ZERO_ERROR || status == U_STRING_NOT_TERMINATED_WARNING; |
275 } | 274 } |
OLD | NEW |