mirror of
git://git.psyced.org/git/psyced
synced 2024-08-15 03:25:10 +00:00
32 lines
874 B
C
32 lines
874 B
C
// $Id: common.c,v 1.8 2005/03/14 10:23:28 lynx Exp $ // vim:syntax=lpc
|
|
//
|
|
// yes even we can't avoid having XML parsing classes
|
|
// used by jabber and RSS (place/news)
|
|
//
|
|
#include <interface.h>
|
|
|
|
#include "xml.h"
|
|
|
|
string xmlquote(string s) {
|
|
// return xml escaped version of s
|
|
s = replace(s, "&", "&");
|
|
s = replace(s, "<", "<");
|
|
s = replace(s, ">", ">");
|
|
s = replace(s, "\"", """);
|
|
s = replace(s, "'", "'");
|
|
return s;
|
|
}
|
|
|
|
string xmlunquote(string s) {
|
|
// return unquoted xml version of s
|
|
s = replace(s, "&", "&");
|
|
s = replace(s, "<", "<");
|
|
s = replace(s, ">", ">");
|
|
s = replace(s, """, "\"");
|
|
s = replace(s, "'", "'");
|
|
// should this take care of ß-style thingies
|
|
// s = regreplace(s, "ß", 223);
|
|
s = regreplace(s, "&#[0-9][0-9][0-9];",
|
|
(: return sprintf("%c", to_int($1[2..<2])); :), 1);
|
|
return s;
|
|
}
|