Configure third-party providers
RFC-4180, paragraph "If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote." –
tommed
Feb 18, 2015 at 16:35
5
As tommed says you only need to add a single double quote to escape a double quote. You can use a command-line tool called csvfix to detect any lines which don't conform: csvfix check -nl -v [filename] –
Sam Critchley
Jun 30, 2016 at 14:51
4
@SamCritchley I only see a single double quote being used to escape here. By "Use 2 quotes", user4035 means that 1 quote should be replaced with 2 quotes. By escaping double quotes with double quotes, you're effectively creating pairs of double quotes (2 double quotes). The final quote you see on the end is to terminate the field. –
Zenexer
Sep 9, 2016 at 3:11
Really nice approach. But this requires me to modify the CSV file before parsing. –
remy727
Sep 20, 2020 at 15:43
1
@GarfieldCat Try this: "world,"",hello" –
user4035
Dec 27, 2020 at 9:54
rewrite ^/feed.rss$ /feed last;
using System;
public class Program
{
public static void Main()
{
try{
GetImage(2);
}
catch(ArgumentException e){
Console.WriteLine( int.Parse(e.Message));
}
}
public static string GetImage(int index){
if(index == 1){ return "/img/1";}
throw new ArgumentException("5");
}
}
using System;
public class Program
{
public static void Main()
{
Object r = GetImage(1);
Check(r);
r = GetImage(2);
Check(r);
}
public static void Check(Object o){
if(o is String) Console.WriteLine("string");
if(o is int) Console.WriteLine("int");
else
Console.WriteLine(o.GetType());
}
public static Object GetImage(int index){
if(index == 1){ return "/img/1";}
return 5;
}
}