OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tools/convert_dict/aff_reader.h" | 5 #include "chrome/tools/convert_dict/aff_reader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 return true; | 133 return true; |
134 } | 134 } |
135 | 135 |
136 bool AffReader::EncodingToUTF8(const std::string& encoded, | 136 bool AffReader::EncodingToUTF8(const std::string& encoded, |
137 std::string* utf8) const { | 137 std::string* utf8) const { |
138 std::wstring wide_word; | 138 std::wstring wide_word; |
139 if (!base::CodepageToWide(encoded, encoding(), | 139 if (!base::CodepageToWide(encoded, encoding(), |
140 base::OnStringConversionError::FAIL, &wide_word)) | 140 base::OnStringConversionError::FAIL, &wide_word)) |
141 return false; | 141 return false; |
142 *utf8 = WideToUTF8(wide_word); | 142 *utf8 = base::WideToUTF8(wide_word); |
143 return true; | 143 return true; |
144 } | 144 } |
145 | 145 |
146 int AffReader::GetAFIndexForAFString(const std::string& af_string) { | 146 int AffReader::GetAFIndexForAFString(const std::string& af_string) { |
147 std::map<std::string, int>::iterator found = affix_groups_.find(af_string); | 147 std::map<std::string, int>::iterator found = affix_groups_.find(af_string); |
148 if (found != affix_groups_.end()) | 148 if (found != affix_groups_.end()) |
149 return found->second; | 149 return found->second; |
150 std::string my_string(af_string); | 150 std::string my_string(af_string); |
151 return AddAffixGroup(&my_string); | 151 return AddAffixGroup(&my_string); |
152 } | 152 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 void AffReader::HandleEncodedCommand(const std::string& line) { | 328 void AffReader::HandleEncodedCommand(const std::string& line) { |
329 std::string utf8; | 329 std::string utf8; |
330 if (!EncodingToUTF8(line, &utf8)) { | 330 if (!EncodingToUTF8(line, &utf8)) { |
331 printf("ERROR: Cannot encode command '%s' to utf8.\n", line.c_str()); | 331 printf("ERROR: Cannot encode command '%s' to utf8.\n", line.c_str()); |
332 exit(1); | 332 exit(1); |
333 } | 333 } |
334 other_commands_.push_back(utf8); | 334 other_commands_.push_back(utf8); |
335 } | 335 } |
336 | 336 |
337 } // namespace convert_dict | 337 } // namespace convert_dict |
OLD | NEW |