OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/ftp/ftp_util.h" | 5 #include "net/ftp/ftp_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
11 #include "base/i18n/char_iterator.h" | 11 #include "base/i18n/char_iterator.h" |
| 12 #include "base/i18n/unicodestring.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
17 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
18 #include "base/strings/string_tokenizer.h" | 19 #include "base/strings/string_tokenizer.h" |
19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // If we cannot get format symbols for some locale, it's not a fatal | 169 // If we cannot get format symbols for some locale, it's not a fatal |
169 // error. Just try another one. | 170 // error. Just try another one. |
170 if (U_FAILURE(status)) | 171 if (U_FAILURE(status)) |
171 continue; | 172 continue; |
172 | 173 |
173 int32_t months_count; | 174 int32_t months_count; |
174 const icu::UnicodeString* months = | 175 const icu::UnicodeString* months = |
175 format_symbols.getShortMonths(months_count); | 176 format_symbols.getShortMonths(months_count); |
176 | 177 |
177 for (int32_t month = 0; month < months_count; month++) { | 178 for (int32_t month = 0; month < months_count; month++) { |
178 base::string16 month_name(months[month].getBuffer(), | 179 base::string16 month_name( |
179 static_cast<size_t>(months[month].length())); | 180 base::i18n::UnicodeStringToString16(months[month])); |
180 | 181 |
181 // Ignore the case of the month names. The simplest way to handle that | 182 // Ignore the case of the month names. The simplest way to handle that |
182 // is to make everything lowercase. | 183 // is to make everything lowercase. |
183 month_name = base::i18n::ToLower(month_name); | 184 month_name = base::i18n::ToLower(month_name); |
184 | 185 |
185 map_[month_name] = month + 1; | 186 map_[month_name] = month + 1; |
186 | 187 |
187 // Sometimes ICU returns longer strings, but in FTP listings a shorter | 188 // Sometimes ICU returns longer strings, but in FTP listings a shorter |
188 // abbreviation is used (for example for the Russian locale). Make sure | 189 // abbreviation is used (for example for the Russian locale). Make sure |
189 // we always have a map entry for a three-letter abbreviation. | 190 // we always have a map entry for a three-letter abbreviation. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 while (!iter.end() && !u_isspace(iter.get())) | 366 while (!iter.end() && !u_isspace(iter.get())) |
366 iter.Advance(); | 367 iter.Advance(); |
367 } | 368 } |
368 | 369 |
369 base::string16 result(text.substr(iter.array_pos())); | 370 base::string16 result(text.substr(iter.array_pos())); |
370 base::TrimWhitespace(result, base::TRIM_ALL, &result); | 371 base::TrimWhitespace(result, base::TRIM_ALL, &result); |
371 return result; | 372 return result; |
372 } | 373 } |
373 | 374 |
374 } // namespace net | 375 } // namespace net |
OLD | NEW |