Fawkes API
Fawkes Development Version
string_urlescape.h
1
/***************************************************************************
2
* string_urlescape.h - Fawkes string URL escape utils
3
*
4
* Created: Fri Oct 24 09:31:39 2008
5
* Copyright 2006-2007 Tim Niemueller [www.niemueller.de]
6
*
7
****************************************************************************/
8
9
/* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version. A runtime exception applies to
13
* this software (see LICENSE.GPL_WRE file mentioned below for details).
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL_WRE file in the doc directory.
21
*/
22
23
#ifndef _UTILS_MISC_STRING_URLESCAPE_H_
24
#define _UTILS_MISC_STRING_URLESCAPE_H_
25
26
namespace
fawkes
{
27
28
/** Transform hex to value.
29
* @param c character
30
* @return value of hex code as number
31
*/
32
int
33
unhex
(
char
c)
34
{
35
return
(c >=
'0'
&& c <= '9' ? c - '0' : c >=
'A'
&& c <=
'F'
? c -
'A'
+ 10 : c -
'a'
+ 10);
36
}
37
38
/** Remove URL hex escapes from s in place.
39
* @param s string to manipulate
40
*/
41
void
42
hex_unescape
(
char
*s)
43
{
44
char
*p;
45
46
for
(p = s; *s !=
'\0'
; ++s) {
47
if
(*s ==
'%'
) {
48
if
(*++s !=
'\0'
) {
49
*p =
unhex
(*s) << 4;
50
}
51
if
(*++s !=
'\0'
) {
52
*p++ +=
unhex
(*s);
53
}
54
}
else
{
55
*p++ = *s;
56
}
57
}
58
59
*p =
'\0'
;
60
}
61
62
}
// end namespace fawkes
63
64
#endif
fawkes::unhex
int unhex(char c)
Transform hex to value.
Definition:
string_urlescape.h:33
fawkes
Fawkes library namespace.
fawkes::hex_unescape
void hex_unescape(char *s)
Remove URL hex escapes from s in place.
Definition:
string_urlescape.h:42
src
libs
utils
misc
string_urlescape.h
Generated by
1.8.20