0

The ASP.NET application that I've been working on parses regular quotes and symbols happily. Other than the smart quotes in the CSV file created using MS Excel.

The following is the code I use:

for (int i = 0; i < ds.Tables["Comments"].Rows.Count; i++) {
value = ParseSmartQuotes(ds.Tables["Comments"].Rows[i][col.FieldName].ToString());

Within the ParseSmartQuotes method, I tried a lot of things. Some of them include:

A solution to replace the smart quotes with regular quotes (or) display the smart quotes as such in the web page would be highly appreciated.

Community
  • 1
  • 1
Aswin Ramakrishnan
  • 3,195
  • 2
  • 41
  • 65

2 Answers2

1

Your parsing code shouldn't be confused by smart quotes. The parser should only look for ASCII quotes as delimiters; smart quotes should be regarded as content--not delimiters--and stored as Unicode.

Is your parser written from scratch? If so, why? There is a high-quality CSV reader available that has worked well for me. It doesn't have any special handling for smart quotes, but it handles Unicode.

Justin M. Keyes
  • 6,679
  • 3
  • 33
  • 60
0

One of the replies within the second link mentions html encoding the text. Have you tried that? Here is the link:

http://msdn.microsoft.com/en-us/library/73z22y6h.aspx

evasilchenko
  • 1,862
  • 1
  • 13
  • 26