| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include <ctype.h> | 9 #include <ctype.h> |
| 10 #include <errno.h> | 10 #include <errno.h> |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 const char kWhitespaceASCII[] = { | 383 const char kWhitespaceASCII[] = { |
| 384 0x09, // <control-0009> to <control-000D> | 384 0x09, // <control-0009> to <control-000D> |
| 385 0x0A, | 385 0x0A, |
| 386 0x0B, | 386 0x0B, |
| 387 0x0C, | 387 0x0C, |
| 388 0x0D, | 388 0x0D, |
| 389 0x20, // Space | 389 0x20, // Space |
| 390 0 | 390 0 |
| 391 }; | 391 }; |
| 392 | 392 |
| 393 const char kUtf8ByteOrderMark[] = "\xEF\xBB\xBF"; |
| 394 |
| 393 template<typename STR> | 395 template<typename STR> |
| 394 TrimPositions TrimStringT(const STR& input, | 396 TrimPositions TrimStringT(const STR& input, |
| 395 const typename STR::value_type trim_chars[], | 397 const typename STR::value_type trim_chars[], |
| 396 TrimPositions positions, | 398 TrimPositions positions, |
| 397 STR* output) { | 399 STR* output) { |
| 398 // Find the edges of leading/trailing whitespace as desired. | 400 // Find the edges of leading/trailing whitespace as desired. |
| 399 const typename STR::size_type last_char = input.length() - 1; | 401 const typename STR::size_type last_char = input.length() - 1; |
| 400 const typename STR::size_type first_good_char = (positions & TRIM_LEADING) ? | 402 const typename STR::size_type first_good_char = (positions & TRIM_LEADING) ? |
| 401 input.find_first_not_of(trim_chars) : 0; | 403 input.find_first_not_of(trim_chars) : 0; |
| 402 const typename STR::size_type last_good_char = (positions & TRIM_TRAILING) ? | 404 const typename STR::size_type last_good_char = (positions & TRIM_TRAILING) ? |
| (...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 // Each input byte creates two output hex characters. | 1812 // Each input byte creates two output hex characters. |
| 1811 std::string ret(size * 2, '\0'); | 1813 std::string ret(size * 2, '\0'); |
| 1812 | 1814 |
| 1813 for (size_t i = 0; i < size; ++i) { | 1815 for (size_t i = 0; i < size; ++i) { |
| 1814 char b = reinterpret_cast<const char*>(bytes)[i]; | 1816 char b = reinterpret_cast<const char*>(bytes)[i]; |
| 1815 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; | 1817 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; |
| 1816 ret[(i * 2) + 1] = kHexChars[b & 0xf]; | 1818 ret[(i * 2) + 1] = kHexChars[b & 0xf]; |
| 1817 } | 1819 } |
| 1818 return ret; | 1820 return ret; |
| 1819 } | 1821 } |
| OLD | NEW |