Azavea.NijPredictivePolicing.Common.Data.CommaSeparatedValueWriter.QuoteAndEscape C# (CSharp) Method

QuoteAndEscape() public method

If input contains ,s or newlines, escapes all "s and brackets in "s and returns the result, otherwise returns input unmodified
public QuoteAndEscape ( string input ) : string
input string The string to escape and quote (if necessary)
return string
        public string QuoteAndEscape(string input)
        {
            if (input.Contains('\n') || input.Contains(','))
            {
                string temp = input.Replace("\"", "\"\"");
                StringBuilder result = new StringBuilder(temp.Length + 2);
                result.Append('\"').Append(temp).Append('\"');
                return result.ToString();
            }
            else
            {
                return input;
            }
        }