Offers interface to encode/decode strings format suitable for URLs.
URLEncodeString | Offers interface to encode/decode strings format suitable for URLs. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file URLEncodeString. |
C-kern/ | Implementation file URLEncodeString impl. |
URLEncoding. | All functions assumes that strings are utf8 encoded. |
Functions | |
test | |
unittest_string_urlencode | Test url encoding/decoding of strings. |
string_t | |
query | |
sizeurlencode_string | Determines url encoded length of parameter str. |
sizeurldecode_string | Determines url decoded length of parameter str. |
urlencoding | |
urlencode_string | Encodes string str to url encoding. |
urldecode_string | Decodes a URL encoded string. |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2011 Jörg Seebohn
Header file URLEncodeString.
Implementation file URLEncodeString impl.
test | |
unittest_string_urlencode | Test url encoding/decoding of strings. |
query | |
sizeurlencode_string | Determines url encoded length of parameter str. |
sizeurldecode_string | Determines url decoded length of parameter str. |
urlencoding | |
urlencode_string | Encodes string str to url encoding. |
urldecode_string | Decodes a URL encoded string. |
int urlencode_string( const struct string_t * str, uint8_t except_char, uint8_t changeto_char, /*ret*/struct wbuffer_t * result )
Encodes string str to url encoding. URL encoding assumes utf8 or ascii encoded strings. Every octet is encoded individually. Alphanumeric characters (“A-Z”, “a-z”, “0-9”) are not changed and directly written to the output. Character codes which are neither alphanumeric nor one of “-_.*” are written as triplet of ‘%’ plus two hexadecimal digits.
If parameter except_char is set to 0 no exception is made during encoding. If it is set to a value != 0 the character is not encoded but changed into the character given in parameter changeto_char.
Set except_char to ‘/’ and changeto_char to ‘/’ if the path of a URL is to be encoded cause ‘/’ is considered a normal character for a path.
Set except_char to ‘ ‘ and changeto_char to ‘+’ if a formdata field is to be encoded.
int urldecode_string( const struct string_t * str, uint8_t changefrom_char, uint8_t changeinto_char, /*ret*/struct wbuffer_t * result )
Decodes a URL encoded string. The decoded string is equal or smaller in size.
Set parameter changefrom_char to value ‘+’ and changeinto_char to value ‘ ‘ in case a formdata field is decoded.
Else set changefrom_char to 0 so no character is changed therefore changeinto_char is never used.
Test url encoding/decoding of strings.
int unittest_string_urlencode( void )
Determines url encoded length of parameter str.
size_t sizeurlencode_string( const struct string_t * str, uint8_t except_char )
Determines url decoded length of parameter str.
size_t sizeurldecode_string( const struct string_t * str )
Encodes string str to url encoding.
int urlencode_string( const struct string_t * str, uint8_t except_char, uint8_t changeto_char, /*ret*/struct wbuffer_t * result )
Decodes a URL encoded string.
int urldecode_string( const struct string_t * str, uint8_t changefrom_char, uint8_t changeinto_char, /*ret*/struct wbuffer_t * result )