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 <algorithm> | |
6 | |
7 #include "net/base/escape.h" | 5 #include "net/base/escape.h" |
8 | 6 |
9 #include "base/i18n/icu_string_conversions.h" | 7 #include "base/i18n/icu_string_conversions.h" |
10 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
11 | 9 |
12 // This file exists to avoid having escape.cc depend on ICU. | 10 // This file exists to avoid having escape.cc depend on ICU. |
13 | 11 |
14 bool EscapeQueryParamValue(const string16& text, const char* codepage, | 12 namespace net { |
15 bool use_plus, string16* escaped) { | 13 |
| 14 bool EscapeQueryParamValue(const string16& text, |
| 15 const char* codepage, |
| 16 bool use_plus, |
| 17 string16* escaped) { |
16 // TODO(brettw) bug 1201094: this function should be removed, this "SKIP" | 18 // TODO(brettw) bug 1201094: this function should be removed, this "SKIP" |
17 // behavior is wrong when the character can't be encoded properly. | 19 // behavior is wrong when the character can't be encoded properly. |
18 std::string encoded; | 20 std::string encoded; |
19 if (!base::UTF16ToCodepage(text, codepage, | 21 if (!base::UTF16ToCodepage(text, codepage, |
20 base::OnStringConversionError::SKIP, &encoded)) | 22 base::OnStringConversionError::SKIP, &encoded)) |
21 return false; | 23 return false; |
22 | 24 |
23 escaped->assign(UTF8ToUTF16(EscapeQueryParamValue(encoded, use_plus))); | 25 escaped->assign(UTF8ToUTF16(EscapeQueryParamValue(encoded, use_plus))); |
24 return true; | 26 return true; |
25 } | 27 } |
| 28 |
| 29 } // namespace net |
OLD | NEW |