henrike@webrtc.org | f7795df | 2014-05-13 18:00:26 +0000 | [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 | |
| 16 | // Decode all encoded characters. Also decode + as space. |
| 17 | int UrlDecode(const char *source, char *dest); |
| 18 | |
| 19 | // Decode all encoded characters. |
| 20 | int UrlDecodeWithoutEncodingSpaceAsPlus(const char *source, char *dest); |
| 21 | |
| 22 | // Encode all characters except alphas, numbers, and -_.!~*'() |
| 23 | // Also encode space as +. |
| 24 | int UrlEncode(const char *source, char *dest, unsigned max); |
| 25 | |
| 26 | // Encode all characters except alphas, numbers, and -_.!~*'() |
| 27 | int UrlEncodeWithoutEncodingSpaceAsPlus(const char *source, char *dest, |
| 28 | unsigned max); |
| 29 | |
| 30 | // Encode only unsafe chars, including \ "^&`<>[]{} |
| 31 | // Also encode space as %20, instead of + |
| 32 | int UrlEncodeOnlyUnsafeChars(const char *source, char *dest, unsigned max); |
| 33 | |
| 34 | std::string UrlDecodeString(const std::string & encoded); |
| 35 | std::string UrlDecodeStringWithoutEncodingSpaceAsPlus( |
| 36 | const std::string & encoded); |
| 37 | std::string UrlEncodeString(const std::string & decoded); |
| 38 | std::string UrlEncodeStringWithoutEncodingSpaceAsPlus( |
| 39 | const std::string & decoded); |
| 40 | std::string UrlEncodeStringForOnlyUnsafeChars(const std::string & decoded); |
| 41 | |
| 42 | #endif |
| 43 | |