Added handling of \ within srings by using \\

This commit is contained in:
Robert Osfield
2008-05-27 16:32:17 +00:00
parent 526f8cd8dc
commit 7ab1219ea3
2 changed files with 29 additions and 6 deletions

View File

@@ -184,10 +184,19 @@ bool FieldReader::_readField(Field* fieldPtr)
return fieldPtr && fieldPtr->getNoCharacters()!=0;
}
c = ch;
if (ch=='\\' && !escape)
if (ch=='\\')
{
escape = true;
_fin->ignore(1);
if (escape)
{
escape = false;
_fin->get(c);
if (fieldPtr) fieldPtr->addChar(c);
}
else
{
escape = true;
_fin->ignore(1);
}
}
else if (ch=='"')
{
@@ -237,8 +246,17 @@ bool FieldReader::_readField(Field* fieldPtr)
c = ch;
if (ch=='\\' && !escape)
{
escape = true;
_fin->ignore(1);
if (escape)
{
escape = false;
_fin->get(c);
if (fieldPtr) fieldPtr->addChar(c);
}
else
{
escape = true;
_fin->ignore(1);
}
}
else if (ch=='\'')
{

View File

@@ -111,7 +111,12 @@ std::string Output::wrapString(const std::string& str)
newstring += '"';
for(unsigned int i=0;i<str.size();++i)
{
if (str[i]=='"')
if (str[i]=='\\')
{
newstring += '\\';
newstring += '\\';
}
else if (str[i]=='"')
{
newstring += '\\';
newstring += '"';