[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[help-cgicc] add: escapeString()

From: Karl Pitrich
Subject: [help-cgicc] add: escapeString()
Date: 04 Jun 2003 13:38:23 +0200


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

Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

[Prev in Thread] Current Thread [Next in Thread]