returns true if field has to be quoted
| 1159 | |
| 1160 | // returns true if field has to be quoted |
| 1161 | bool CsvTable::toBeQuoted(std::string field, CsvDefinition definition) { |
| 1162 | if( definition.quoteStyle == CsvDefinition::QUOTE_STYLE_ALL ) { |
| 1163 | return true; |
| 1164 | } |
| 1165 | if( definition.quoteStyle == CsvDefinition::QUOTE_STYLE_STRING && !Helper::isNumber(field) && field != "" ) { |
| 1166 | return true; |
| 1167 | } |
| 1168 | for( char& c : field ) { |
| 1169 | // Line breaks, Field enclosures (double quotes) and Field separators (comma, semicolon, tab, bar) lead to quotation |
| 1170 | if( c == '\n' || c == definition.quote || c == definition.delimiter ) { |
| 1171 | return true; |
| 1172 | } |
| 1173 | } |
| 1174 | return false; |
| 1175 | } |
| 1176 | |
| 1177 | |
| 1178 | // |
nothing calls this directly
no outgoing calls
no test coverage detected