Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
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
29
/** Transform hex to value.
30
* @param c character
31
* @return value of hex code as number
32
*/
33
int
34
unhex
(
char
c)
35
{
36
return
( c >=
'0'
&& c <=
'9'
? c -
'0'
37
: c >=
'A'
&& c <=
'F'
? c -
'A'
+ 10
38
: c -
'a'
+ 10 );
39
}
40
41
/** Remove URL hex escapes from s in place.
42
* @param s string to manipulate
43
*/
44
void
45
hex_unescape
(
char
*s )
46
{
47
char
*p;
48
49
for
( p = s; *s !=
'\0'
; ++s ) {
50
if
( *s ==
'%'
) {
51
if
( *++s !=
'\0'
) {
52
*p =
unhex
( *s ) << 4;
53
}
54
if
( *++s !=
'\0'
) {
55
*p++ +=
unhex
( *s );
56
}
57
}
else
{
58
*p++ = *s;
59
}
60
}
61
62
*p =
'\0'
;
63
}
64
65
66
}
// end namespace fawkes
67
68
#endif
src
libs
utils
misc
string_urlescape.h
Generated by
1.8.1.1