Patch level : 12.0 no-patch

Files correlati     :
Commento            :

xml : Resa possibil la non codifica dei caratteri speciali del tipo '/' -----> &#2F; in scrittura (maialata dovuta all Major Flexform)
This commit is contained in:
Alessandro Bonazzi 2020-11-27 16:01:17 +01:00
parent 046ab1bfed
commit a1a639a457
2 changed files with 13 additions and 1 deletions

View File

@ -6,10 +6,19 @@
#include <incstr.h>
bool __xml_encode_text = true;
bool xml_encode_text(bool on)
{
__xml_encode_text = on;
return __xml_encode_text;
}
///////////////////////////////////////////////////////////
// Utilities
///////////////////////////////////////////////////////////
void Spaces(ostream& outf, int nSpaces)
{
outf << '\n';
@ -98,7 +107,8 @@ void WriteXmlString(ostream& outf, const char* str)
for (int i = 0; str[i]; i++)
{
const char c = str[i];
if ((c < ' ' && c != '\n' && c != '\r') || strchr("<>/&", c) != NULL)
if ((c < ' ' && c != '\n' && c != '\r') ||
(__xml_encode_text && (strchr("<>/&", c) != NULL)))
{
const unsigned int n = (unsigned char)c;
TString8 tmp; tmp.format("&#%02X;", n);

View File

@ -9,6 +9,8 @@ class TXmlItem;
typedef bool (*XmlItemCallback)(TXmlItem& item, long jolly);
bool xml_encode_text(bool on = true);
class TXmlItem : public TObject
{