Changeset 7387


Ignore:
Timestamp:
2004-05-24T16:41:00+12:00 (20 years ago)
Author:
mdewsnip
Message:

(Human Info) Added javascript_safe function.

Location:
trunk/gsdl/src/recpt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/htmlutils.cpp

    r1285 r7387  
    4141  return outstring;
    4242}
     43
     44
     45text_t javascript_safe (const text_t &instring) {
     46
     47  text_t outstring;
     48  text_t::const_iterator here = instring.begin();
     49  text_t::const_iterator end = instring.end();
     50  while (here != end) {
     51    if (*here == '"') outstring += """;
     52    else if (*here == '\'') outstring += "\\'";
     53    else outstring.push_back(*here);
     54    here ++;
     55  }
     56  return outstring;
     57}
  • trunk/gsdl/src/recpt/htmlutils.h

    r1285 r7387  
    3232
    3333text_t html_safe (const text_t &instring);
     34text_t javascript_safe (const text_t &instring);
    3435
    3536#endif
Note: See TracChangeset for help on using the changeset viewer.