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