henrike@webrtc.org | 47be73b | 2014-05-13 18:00:26 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef _URLENCODE_H_ |
| 12 | #define _URLENCODE_H_ |
| 13 | |
| 14 | #include <string> |
| 15 | |
henrike@webrtc.org | b2eea5c | 2014-05-14 18:24:13 | [diff] [blame] | 16 | namespace rtc { |
| 17 | |
henrike@webrtc.org | 47be73b | 2014-05-13 18:00:26 | [diff] [blame] | 18 | // Decode all encoded characters. Also decode + as space. |
| 19 | int UrlDecode(const char *source, char *dest); |
| 20 | |
| 21 | // Decode all encoded characters. |
| 22 | int UrlDecodeWithoutEncodingSpaceAsPlus(const char *source, char *dest); |
| 23 | |
| 24 | // Encode all characters except alphas, numbers, and -_.!~*'() |
| 25 | // Also encode space as +. |
| 26 | int UrlEncode(const char *source, char *dest, unsigned max); |
| 27 | |
| 28 | // Encode all characters except alphas, numbers, and -_.!~*'() |
| 29 | int UrlEncodeWithoutEncodingSpaceAsPlus(const char *source, char *dest, |
| 30 | unsigned max); |
| 31 | |
| 32 | // Encode only unsafe chars, including \ "^&`<>[]{} |
| 33 | // Also encode space as %20, instead of + |
| 34 | int UrlEncodeOnlyUnsafeChars(const char *source, char *dest, unsigned max); |
| 35 | |
| 36 | std::string UrlDecodeString(const std::string & encoded); |
| 37 | std::string UrlDecodeStringWithoutEncodingSpaceAsPlus( |
| 38 | const std::string & encoded); |
| 39 | std::string UrlEncodeString(const std::string & decoded); |
| 40 | std::string UrlEncodeStringWithoutEncodingSpaceAsPlus( |
| 41 | const std::string & decoded); |
| 42 | std::string UrlEncodeStringForOnlyUnsafeChars(const std::string & decoded); |
| 43 | |
| 44 | #endif |
| 45 | |
henrike@webrtc.org | b2eea5c | 2014-05-14 18:24:13 | [diff] [blame] | 46 | } // namespace rtc |