1 #include "ACEXML/common/XML_Util.h"
3 static const ACEXML_Char ESCAPED_AMP
[] = ACE_TEXT("&");
4 static const ACEXML_Char ESCAPED_LESS
[] = ACE_TEXT("<");
5 static const ACEXML_Char ESCAPED_GREATER
[] = ACE_TEXT(">");
6 static const ACEXML_Char ESCAPED_APOS
[] = ACE_TEXT("'");
7 static const ACEXML_Char ESCAPED_QUOTE
[] = ACE_TEXT(""");
9 #define CSTRLEN(x) ((sizeof(x) / sizeof(ACEXML_Char)) - 1)
11 ACEXML_String
ACEXML_escape_string(const ACEXML_String
& str
)
13 ACEXML_String
ret(str
.length ());
14 ACEXML_escape_string(str
, ret
);
18 void ACEXML_escape_string(const ACEXML_String
& in
, ACEXML_String
& out
)
20 size_t len
= in
.length ();
22 for (size_t stridx
= 0; stridx
< len
; ++stridx
)
26 out
.append(ESCAPED_AMP
, CSTRLEN(ESCAPED_AMP
));
29 out
.append(ESCAPED_LESS
, CSTRLEN(ESCAPED_LESS
));
32 out
.append(ESCAPED_GREATER
, CSTRLEN(ESCAPED_GREATER
));
35 out
.append(ESCAPED_APOS
, CSTRLEN(ESCAPED_APOS
));
38 out
.append(ESCAPED_QUOTE
, CSTRLEN(ESCAPED_QUOTE
));