add: escapeString()
Karl Pitrich <[email protected]> 04 Jun 2003 13:38:23 +0200
| Newsgroups | gmane.comp.gcc.cgicc.general |
|---|---|
| Organization | fabasoft ag |
| Message-ID | <[email protected]> |
hi,
i added a _simple_ escapeString() to CgiUtils.cpp, maybe it is usefult
to someone else.
as it is really not much code, i paste it plainly instead of a diff.
/ karl
static const char *hex_chars = "0123456789ABCDEF";
static bool is_save(char c) {
if((c >= '0' && c <= '9')
|| (c >= 'A' && c <= 'Z')
|| (c >= 'a' && c <= 'z'))
return true;
return false;
}
STDNS string
CGICCNS escapeString(const STDNS string& src)
{
STDNS string result;
STDNS string::const_iterator iter;
for(iter = src.begin(); iter != src.end(); ++iter) {
if(is_save(*iter)) {
result.append(1, *iter);
} else {
result.append(1, '%');
result.append(1, hex_chars[*iter >> 4]);
result.append(1, hex_chars[*iter & 15]);
}
}
return result;
}
--
Karl Pitrich [GCS C+++ L UL+++ L++++ P--- E--- w--- PGP++ t+++]
doin' the Linux at
Fabasoft R&D Software GmbH & Co KG, Linz, Austria
_______________________________________________
help-cgicc mailing list
[email protected]
http://mail.gnu.org/mailman/listinfo/help-cgicc
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQA+3dovhjEylB2OKukRAsmQAJ9jBmlenDklsCMNgVFxmnLdKoFkawCfWj/V fzww3j1iuKGrIue8wJGe9FY= =Pwf2 -----END PGP SIGNATURE-----