added: to Request options used by ezc generators:

bool gen_trim_white;
       bool gen_skip_new_line;
       bool gen_use_special_chars;
added: new ezc filter: fil_csv_escape
       for escaping csv fields





git-svn-id: svn://ttmath.org/publicrep/winix/trunk@877 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-08-26 19:53:47 +00:00
parent adf273479a
commit 260c12894d
9 changed files with 102 additions and 1 deletions

View File

@@ -97,4 +97,43 @@ void fil_first_wordup(Info & i)
}
bool fil_csv_has_colon_or_quote(const std::wstring & str)
{
for(size_t i=0 ; i<str.size() ; ++i)
{
if( str[i] == ',' || str[i] == '"' )
return true;
}
return false;
}
void fil_csv_escape(Info & i)
{
const std::wstring & str = i.in.Str();
if( fil_csv_has_colon_or_quote(str) )
{
i.out << R("\"");
for(size_t a=0 ; a<str.size() ; ++a)
{
if( str[a] == '"' )
i.out << R("\"\"");
else
i.out << R(str[a]);
}
i.out << R("\"");
}
else
{
i.out << R(str);
}
}
} // namespace