Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(764)

Side by Side Diff: chrome/tools/convert_dict/hunspell_reader.cc

Issue 267001: Separate out some more ICU from base and into base/i18n.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/new_profile_dialog.cc ('k') | net/base/directory_lister.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/tools/convert_dict/hunspell_reader.h" 5 #include "chrome/tools/convert_dict/hunspell_reader.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 8
9 namespace convert_dict { 9 namespace convert_dict {
10 10
11 // This silly 64K buffer is just copied from Hunspell's way of parsing. 11 // This silly 64K buffer is just copied from Hunspell's way of parsing.
12 const int kLineBufferLen = 65535; 12 const int kLineBufferLen = 65535;
13 char line_buffer[kLineBufferLen]; 13 char line_buffer[kLineBufferLen];
14 14
15 // Shortcut for trimming whitespace from both ends of the line. 15 // Shortcut for trimming whitespace from both ends of the line.
16 void TrimLine(std::string* line) { 16 void TrimLine(std::string* line) {
17 if (line->size() > 3 && 17 if (line->size() > 3 &&
18 static_cast<unsigned char>((*line)[0]) == 0xef && 18 static_cast<unsigned char>((*line)[0]) == 0xef &&
19 static_cast<unsigned char>((*line)[1]) == 0xbb && 19 static_cast<unsigned char>((*line)[1]) == 0xbb &&
20 static_cast<unsigned char>((*line)[2]) == 0xbf) 20 static_cast<unsigned char>((*line)[2]) == 0xbf)
21 *line = line->substr(3); 21 *line = line->substr(3);
22 22
23 TrimWhitespaceUTF8(*line, TRIM_ALL, line); 23 std::wstring line_input_wide = UTF8ToWide(*line);
24 std::wstring line_output_wide;
25 TrimWhitespace(line_input_wide, TRIM_ALL, &line_output_wide);
26 *line = WideToUTF8(line_output_wide);
24 } 27 }
25 28
26 std::string ReadLine(FILE* file) { 29 std::string ReadLine(FILE* file) {
27 const char* line = fgets(line_buffer, kLineBufferLen - 1, file); 30 const char* line = fgets(line_buffer, kLineBufferLen - 1, file);
28 if (!line) 31 if (!line)
29 return std::string(); 32 return std::string();
30 33
31 std::string str = line; 34 std::string str = line;
32 TrimLine(&str); 35 TrimLine(&str);
33 return str; 36 return str;
34 } 37 }
35 38
36 void StripComment(std::string* line) { 39 void StripComment(std::string* line) {
37 for (size_t i = 0; i < line->size(); i++) { 40 for (size_t i = 0; i < line->size(); i++) {
38 if ((*line)[i] == '#') { 41 if ((*line)[i] == '#') {
39 line->resize(i); 42 line->resize(i);
40 TrimLine(line); 43 TrimLine(line);
41 return; 44 return;
42 } 45 }
43 } 46 }
44 } 47 }
45 48
46 } // namespace convert_dict 49 } // namespace convert_dict
OLDNEW
« no previous file with comments | « chrome/browser/views/new_profile_dialog.cc ('k') | net/base/directory_lister.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698