| 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 "base/string_util.h" | 5 #include "base/string_util.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output) { | 191 bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output) { |
| 192 if (src_len == 0) { | 192 if (src_len == 0) { |
| 193 output->clear(); | 193 output->clear(); |
| 194 return true; | 194 return true; |
| 195 } | 195 } |
| 196 | 196 |
| 197 ReserveUTF8Output(src, src_len, output); | 197 ReserveUTF8Output(src, src_len, output); |
| 198 return ConvertUnicode<wchar_t, std::string>(src, src_len, output); | 198 return ConvertUnicode<wchar_t, std::string>(src, src_len, output); |
| 199 } | 199 } |
| 200 | 200 |
| 201 std::wstring UTF8ToWide(const std::string& utf8) { | 201 std::wstring UTF8ToWide(const StringPiece& utf8) { |
| 202 std::wstring ret; | 202 std::wstring ret; |
| 203 if (utf8.empty()) | 203 if (utf8.empty()) |
| 204 return ret; | 204 return ret; |
| 205 | 205 |
| 206 UTF8ToWide(utf8.data(), utf8.length(), &ret); | 206 UTF8ToWide(utf8.data(), utf8.length(), &ret); |
| 207 return ret; | 207 return ret; |
| 208 } | 208 } |
| 209 | 209 |
| 210 bool UTF8ToWide(const char* src, size_t src_len, std::wstring* output) { | 210 bool UTF8ToWide(const char* src, size_t src_len, std::wstring* output) { |
| 211 if (src_len == 0) { | 211 if (src_len == 0) { |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 u_strToWCS(buffer, 64, &length, ustr.getBuffer(), ustr.length() , &error); | 523 u_strToWCS(buffer, 64, &length, ustr.getBuffer(), ustr.length() , &error); |
| 524 if (U_FAILURE(error)) { | 524 if (U_FAILURE(error)) { |
| 525 NOTREACHED(); | 525 NOTREACHED(); |
| 526 // As a fallback, just return the raw number in a string. | 526 // As a fallback, just return the raw number in a string. |
| 527 return StringPrintf(L"%lld", number); | 527 return StringPrintf(L"%lld", number); |
| 528 } | 528 } |
| 529 return std::wstring(buffer, static_cast<std::wstring::size_type>(length)); | 529 return std::wstring(buffer, static_cast<std::wstring::size_type>(length)); |
| 530 #endif // defined(WCHAR_T_IS_UTF32) | 530 #endif // defined(WCHAR_T_IS_UTF32) |
| 531 } | 531 } |
| 532 | 532 |
| OLD | NEW |