summaryrefslogtreecommitdiffstats
path: root/net/base/escape.cc
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 01:10:46 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 01:10:46 +0000
commitb8c1eb454dc4f246c64a6b1b5b472af102e88103 (patch)
tree6413d1400ee4ade44838ecd530736840d1f4f64b /net/base/escape.cc
parentbe2da4de5227f4f1cbb8455a58045c5e51076474 (diff)
downloadchromium_src-b8c1eb454dc4f246c64a6b1b5b472af102e88103.zip
chromium_src-b8c1eb454dc4f246c64a6b1b5b472af102e88103.tar.gz
chromium_src-b8c1eb454dc4f246c64a6b1b5b472af102e88103.tar.bz2
base: Add IsHexDigit function to string_util.h
Removed duplicated IsHex functions and converted the callers along the way. (Note: this was a TODO for jungshik). BUG=None TEST=trybots Signed-off-by: Thiago Farina <tfarina@chromium.org> Review URL: http://codereview.chromium.org/2870058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53428 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/escape.cc')
-rw-r--r--net/base/escape.cc12
1 files changed, 3 insertions, 9 deletions
diff --git a/net/base/escape.cc b/net/base/escape.cc
index bc01e11..d9bfcee 100644
--- a/net/base/escape.cc
+++ b/net/base/escape.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,19 +9,13 @@
#include "base/i18n/icu_string_conversions.h"
#include "base/logging.h"
#include "base/string_piece.h"
+#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/utf_offset_string_conversions.h"
namespace {
template <class char_type>
-inline bool IsHex(char_type ch) {
- return (ch >= '0' && ch <= '9') ||
- (ch >= 'A' && ch <= 'F') ||
- (ch >= 'a' && ch <= 'f');
-}
-
-template <class char_type>
inline char_type HexToInt(char_type ch) {
if (ch >= '0' && ch <= '9')
return ch - '0';
@@ -141,7 +135,7 @@ STR UnescapeURLImpl(const STR& escaped_text,
static_cast<typename STR::value_type>(escaped_text[i + 1]));
const typename STR::value_type least_sig_digit(
static_cast<typename STR::value_type>(escaped_text[i + 2]));
- if (IsHex(most_sig_digit) && IsHex(least_sig_digit)) {
+ if (IsHexDigit(most_sig_digit) && IsHexDigit(least_sig_digit)) {
unsigned char value = HexToInt(most_sig_digit) * 16 +
HexToInt(least_sig_digit);
if (value >= 0x80 || // Unescape all high-bit characters.