Go to the source code of this file.
High Performance URL Encoder/Decoder
Copyright © 2006, 2007 Nick Galbreath -- nickg [at] modp [dot] com
All rights reserved.
http://code.google.com/p/stringencoders/
Released under bsd license. See bfast64.c for details.
◆ modp_burl_decode_len
#define modp_burl_decode_len |
( |
|
A | ) |
(A + 1) |
Returns memory required to decoded a url-encoded string of length A.
◆ modp_burl_encode_len
#define modp_burl_encode_len |
( |
|
A | ) |
(3*A + 1) |
Provides the maximum size for output string given and input size of A bytes.
◆ modp_burl_decode()
int modp_burl_decode |
( |
char * |
dest, |
|
|
const char * |
str, |
|
|
int |
len |
|
) |
| |
URL Decode a string
- Parameters
-
[out] | dest | The output string. Must be at least (len + 1) bytes allocated. This may be the same as the input buffer. |
[in] | str | The input string that is URL encoded. |
[in] | len | The length of the input string (excluding final null byte) |
- Returns
- the strlen of the output string.
◆ modp_burl_encode()
BEGIN_C int modp_burl_encode |
( |
char * |
dest, |
|
|
const char * |
str, |
|
|
int |
len |
|
) |
| |
Url encode a string. This uses a very strict definition of url encoding. The only characters NOT encoded are A-Z, a-z, 0-9, "-", "_", ".", along with the space char getting mapped to "+". Everything else is escaped using "%HEXHEX" format. This is identical to the implementation of php's urlencode and nearly identical to Java's UrlEncoder class (they do not escape '*' for some reason).
- Parameters
-
[out] | dest | output string. Must |
[in] | str | The input string |
[in] | len | The length of the input string, excluding any final null byte. |
◆ modp_burl_encode_strlen()
int modp_burl_encode_strlen |
( |
const char * |
str, |
|
|
const int |
len |
|
) |
| |
Given the exact size of output string.
Can be used to allocate the right amount of memory for modp_burl_encode. Be sure to add 1 byte for final null.
This is somewhat expensive since it examines every character in the input string
- Parameters
-
[in] | str | The input string |
[in] | len | THe length of the input string, excluding any final null byte (i.e. strlen(str)) |
- Returns
- the size of the output string, excluding the final null byte.
◆ modp_burl_min_encode()
int modp_burl_min_encode |
( |
char * |
dest, |
|
|
const char * |
str, |
|
|
int |
len |
|
) |
| |
Url encode a string. This uses a minimal definition of url encoding. This works similar to the previous function except '~', '!', '$', '\'', '(', ')', '*', ',', ';', ':', '@', '/', '?' are NOT escaped. This will allow decoding by standard url-decoders and make the encoded urls more readable.
- Parameters
-
[out] | dest | output string. Must |
[in] | str | The input string |
[in] | len | The length of the input string, excluding any final null byte. |
◆ modp_burl_min_encode_strlen()
int modp_burl_min_encode_strlen |
( |
const char * |
src, |
|
|
const int |
len |
|
) |
| |
get size of output string w/o doing actual encoding
- Parameters
-
[in] | src | input string, not null |
[in] | len | length of input string |
- Returns
- length of output string NOT including any final null byte